port parse
This commit is contained in:
@@ -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))
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user