diff --git a/main.go b/main.go index 4bfa657..d6b7c78 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "database/sql" + "embed" "encoding/json" "errors" "fmt" @@ -21,6 +22,9 @@ import ( "gopkg.in/yaml.v3" ) +//go:embed static +var staticFiles embed.FS + type Config struct { Server ServerConfig `yaml:"server"` PLC PLCConfig `yaml:"plc"` @@ -849,6 +853,8 @@ func main() { go startDBCleanup(db) go startPLCPoller() + // Serve embedded static assets (tailwind.min.js, chart.umd.min.js) + http.Handle("/static/", http.FileServer(http.FS(staticFiles))) http.HandleFunc("/", serveUI) http.HandleFunc("/api/data", apiData) http.HandleFunc("/api/history", apiHistory) @@ -865,11 +871,9 @@ const uiHTML = ` {{.Title}} - - + +