From 1a5a86a5d4557200db20e20206bcdd7b9b2a7e55 Mon Sep 17 00:00:00 2001 From: hovertank3d Date: Sat, 18 Jan 2025 23:27:52 +0100 Subject: refactor and add /about --- main.go | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 main.go (limited to 'main.go') diff --git a/main.go b/main.go deleted file mode 100644 index b7ae65c..0000000 --- a/main.go +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import ( - "html/template" - "log" - "net/http" - "os" - "sync/atomic" - - "embed" -) - -/* -#include -extern unsigned long int log2lzcnt(unsigned long int); -*/ -import "C" - -//go:embed templates -var templates embed.FS - -func main() { - counter := atomic.Uint64{} - host := ":8080" - if len(os.Args) == 2 { - host = os.Args[1] - } - - tmpl, err := template.ParseFS(templates, "templates/*.html") - if err != nil { - log.Fatal(err) - } - - http.HandleFunc("/reset", func(w http.ResponseWriter, r *http.Request) { - counter.Store(0) - http.Redirect(w, r, "/", http.StatusSeeOther) - }) - - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - n := counter.Add(1) - payload := struct { - Requests uint64 - Log2lzcnt uint64 - }{ - Requests: n, - Log2lzcnt: uint64(C.log2lzcnt(C.uint64_t(n))), - } - - tmpl.Execute(w, payload) - }) - - http.ListenAndServe(host, nil) -} -- cgit v1.2.3