From 227de17951402704fe44d806be9c64acaaf9bca0 Mon Sep 17 00:00:00 2001 From: bel Date: Sun, 29 Oct 2023 09:21:06 -0600 Subject: [PATCH] wip --- cmd/http/main.go | 12 +++++++----- cmd/http/public/transactions.html | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/cmd/http/main.go b/cmd/http/main.go index e8679af..6503d93 100644 --- a/cmd/http/main.go +++ b/cmd/http/main.go @@ -27,10 +27,12 @@ import ( //go:embed public/* var _staticFileDir embed.FS -var staticFileDir = func() embed.FS { - panic("if dev mode then return live") - return _staticFileDir -} +var publicHandler = func() http.Handler { + if os.Getenv("DEBUG") != "" { + return http.FileServer(http.Dir("./http")) + } + return http.FileServer(http.FS(_staticFileDir)) +}() func Main() { foo := flag.String("foo", "bal", "bal or reg") @@ -65,7 +67,7 @@ func Main() { if *httpOutput != "" { foo := func(w http.ResponseWriter, r *http.Request) { if !strings.HasPrefix(r.URL.Path, "/api") { - http.FileServer(http.FS(staticFileDir)).ServeHTTP(w, r) + publicHandler.ServeHTTP(w, r) return } diff --git a/cmd/http/public/transactions.html b/cmd/http/public/transactions.html index 8911ea5..789f7ab 100644 --- a/cmd/http/public/transactions.html +++ b/cmd/http/public/transactions.html @@ -37,6 +37,7 @@ var d = JSON.parse(body) loadBalances(d.balances) loadDeltas(d.deltas) + loadLastNLines(d.lastNLines) }) } function loadBalances(balances) { @@ -68,6 +69,14 @@ result += `` document.getElementById("reg").innerHTML = result } + function loadLastNLines(lastNLines) { + var result = `` + document.getElementById("lastNLines").innerHTML = result + } @@ -81,7 +90,12 @@ -
+
+ Edit +
+
+
+
Register