port parse
This commit is contained in:
@@ -2,6 +2,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
@@ -12,6 +14,9 @@ import (
|
|||||||
var sourceFS embed.FS
|
var sourceFS embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
port := flag.Int("port", 8081, "port to listen on")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
staticRoot, err := fs.Sub(sourceFS, "source")
|
staticRoot, err := fs.Sub(sourceFS, "source")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@@ -152,6 +157,8 @@ func main() {
|
|||||||
|
|
||||||
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServerFS(assetsRoot)))
|
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServerFS(assetsRoot)))
|
||||||
|
|
||||||
log.Println("running on http://localhost:8081/")
|
addr := fmt.Sprintf(":%d", *port)
|
||||||
log.Fatal(http.ListenAndServe(":8081", mux))
|
log.Printf("running on http://localhost%s/\n", addr)
|
||||||
|
log.Fatal(http.ListenAndServe(addr, mux))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user