port parse

This commit is contained in:
zipfriis
2026-09-09 14:31:15 +02:00
parent 20c9f134e2
commit 63e0cd66bb
2 changed files with 9 additions and 2 deletions
+9 -2
View File
@@ -2,6 +2,8 @@ package main
import (
"embed"
"flag"
"fmt"
"html/template"
"io/fs"
"log"
@@ -12,6 +14,9 @@ import (
var sourceFS embed.FS
func main() {
port := flag.Int("port", 8081, "port to listen on")
flag.Parse()
staticRoot, err := fs.Sub(sourceFS, "source")
if err != nil {
log.Fatal(err)
@@ -152,6 +157,8 @@ func main() {
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServerFS(assetsRoot)))
log.Println("running on http://localhost:8081/")
log.Fatal(http.ListenAndServe(":8081", mux))
addr := fmt.Sprintf(":%d", *port)
log.Printf("running on http://localhost%s/\n", addr)
log.Fatal(http.ListenAndServe(addr, mux))
}