summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Hurst <julian.hurst92@gmail.com>2020-10-16 10:25:25 +0200
committerJulian Hurst <julian.hurst92@gmail.com>2020-10-16 10:25:25 +0200
commit95389e0e9a62fe01c3c92edb30022913d60cf5b6 (patch)
treefab58fa898cd396621e125ebdcd8dba350c2f9f5
parent9550f76265805e9bfe0616a7834a9eed4d95e368 (diff)
downloadgrimtube-95389e0e9a62fe01c3c92edb30022913d60cf5b6.tar.gz
Add port flag
-rw-r--r--grimtube.go6
1 files changed, 5 insertions, 1 deletions
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))
}