From 95389e0e9a62fe01c3c92edb30022913d60cf5b6 Mon Sep 17 00:00:00 2001 From: Julian Hurst Date: Fri, 16 Oct 2020 10:25:25 +0200 Subject: Add port flag --- grimtube.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'grimtube.go') diff --git a/grimtube.go b/grimtube.go index 416bc7f..ef51f0c 100644 --- a/grimtube.go +++ b/grimtube.go @@ -1,8 +1,10 @@ package main import ( + "flag" "text/template" "net/http" + "fmt" //"io" "log" "strconv" @@ -95,6 +97,8 @@ func favicon(w http.ResponseWriter, r *http.Request) { } func main() { + port := flag.Int("p", 8080, "The port to bind to.") + flag.Parse() fs := http.FileServer(http.Dir("static")) http.Handle("/static/", http.StripPrefix("/static/", fs)) http.HandleFunc("/favicon.ico", favicon) @@ -102,5 +106,5 @@ func main() { http.HandleFunc("/search", search) http.HandleFunc("/embed", embed) - log.Fatal(http.ListenAndServe(":8080", nil)) + log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)) } -- cgit v1.2.3