fix missing link calls

This commit is contained in:
Thomas Klaehn
2023-02-06 11:33:18 +01:00
parent 89a78993b5
commit 8c110e845b
10 changed files with 66 additions and 13 deletions

10
main.go
View File

@@ -2,8 +2,8 @@ package main
import (
"encoding/json"
"flag"
"log"
"mime"
"net/http"
"sync"
@@ -73,6 +73,10 @@ func http_endpoint_sauna(w http.ResponseWriter, r *http.Request) {
func main() {
logger.Println("starting")
var webui_path string
flag.StringVar(&webui_path, "d", "./static", "Specify path to serve the web ui. Default is ./static")
flag.Parse()
// MQTT connection
opts := mqtt.NewClientOptions()
opts.AddBroker("tcp://nuc:1883")
@@ -91,11 +95,9 @@ func main() {
token.Wait()
logger.Printf("Subscribed to topic %s", topic)
mime.AddExtensionType(".js", "text/javascript; charset=utf-8")
mime.AddExtensionType(".css", "text/css; charset=utf-8")
// API routes
// Serve files from static folder
http.Handle("/", http.FileServer(http.Dir("/var/lib/home/")))
http.Handle("/", http.FileServer(http.Dir(webui_path)))
http.HandleFunc("/sauna/sample", http_endpoint_sauna)