No plots yet
-Click + Add Plot then drag signals from the sidebar.
-diff --git a/Client/WebUI/main.go b/Client/WebUI/main.go index f2082b7..9c6b953 100644 --- a/Client/WebUI/main.go +++ b/Client/WebUI/main.go @@ -3,11 +3,16 @@ package main import ( "embed" "flag" + "fmt" + "io/fs" "log" "net/http" ) -//go:embed static/index.html +// version is set at build time via -ldflags "-X main.version=..." +var version = "dev" + +//go:embed static var staticFiles embed.FS func main() { @@ -22,25 +27,19 @@ func main() { udpClient := NewUDPClient(*streamerAddr, *clientPort, hub) go udpClient.Run() - // Serve the embedded index.html at /. - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - if r.URL.Path != "/" { - http.NotFound(w, r) - return - } - data, err := staticFiles.ReadFile("static/index.html") - if err != nil { - http.Error(w, "index.html not found", http.StatusInternalServerError) - return - } - w.Header().Set("Content-Type", "text/html; charset=utf-8") - w.Write(data) + // Serve the embedded static/ directory (index.html, style.css, app.js). + sub, err := fs.Sub(staticFiles, "static") + if err != nil { + log.Fatalf("static sub-fs: %v", err) + } + http.Handle("/", http.FileServer(http.FS(sub))) + http.HandleFunc("/ws", hub.HandleWebSocket) + http.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, version) }) - http.HandleFunc("/ws", hub.HandleWebSocket) - - log.Printf("WebUI listening on %s (streamer=%s, local UDP port=%d)", - *listenAddr, *streamerAddr, *clientPort) + log.Printf("WebUI listening on %s (streamer=%s, local UDP port=%d, version=%s)", + *listenAddr, *streamerAddr, *clientPort, version) if err := http.ListenAndServe(*listenAddr, nil); err != nil { log.Fatalf("http: %v", err) } diff --git a/Client/WebUI/static/index.html b/Client/WebUI/static/index.html index 6fb33ae..f750a5f 100644 --- a/Client/WebUI/static/index.html +++ b/Client/WebUI/static/index.html @@ -4,322 +4,38 @@
Click + Add Plot then drag signals from the sidebar.
-