From c7057d7853c0cc55ba015705b9790cb263e5f10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dejan=20Ro=C5=BEi=C4=8D?= Date: Fri, 17 Apr 2026 09:57:32 +0200 Subject: [PATCH] added static page --- main.go | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) 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}} - - + +