diff --git a/main.go b/main.go index b09e341..9f8da59 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "gitlab.com/golang-commonmark/markdown" "html/template" @@ -409,6 +410,10 @@ func (h *recentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func main() { + var port int + flag.IntVar(&port, "port", 8080, "http port") + flag.Parse() + mp = NewFilePages("data") http.Handle("/auth/", &authHandler{}) @@ -419,6 +424,6 @@ func main() { http.Handle("/recent/", &recentHandler{}) http.Handle("/", &indexHandler{}) - fmt.Printf("Running on port 8080") - log.Fatal(http.ListenAndServe(":8080", nil)) + fmt.Printf("Running on port %d\n", port) + log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil)) }