From 896fe7f0a0101a36bed85235301a0eeebb3570f2 Mon Sep 17 00:00:00 2001 From: Pinghao Wu Date: Thu, 16 Jan 2025 13:57:55 +0800 Subject: [PATCH] optional footer message support --- server.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server.go b/server.go index b9418ed..a85955c 100644 --- a/server.go +++ b/server.go @@ -25,6 +25,7 @@ import ( var ( addr = flag.String("l", "0.0.0.0:8000", "Listen on address") root = flag.String("r", ".", "Root of content") + foot = flag.String("f", "", "Footer message") numfmtSuffix = []string{"", "K", "M", "G", "T"} @@ -99,6 +100,11 @@ var ( th.desc::after { content: '↓'; } + footer { + font-family: monospace; + color: #787878; + padding-top: 12px; + } a { text-decoration: none; } @@ -178,6 +184,9 @@ var ( {{end}} + {{if .Footer}} + + {{end}} `)) @@ -186,6 +195,7 @@ var ( type Data struct { Path string Entries []fs.DirEntry + Footer string } func main() { @@ -229,7 +239,7 @@ func main() { w.WriteHeader(404) return } - tpl.Execute(w, Data{r.URL.Path, ds}) + tpl.Execute(w, Data{r.URL.Path, ds, *foot}) } else { staticHandler.ServeHTTP(w, r) } -- 2.45.2