Specify port with -port argument
All checks were successful
the build was successful

This commit is contained in:
Peter Stuifzand 2019-02-18 20:47:55 +01:00
parent 53bb6bdf23
commit f1695c3136

View File

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