From 69131bb1a5c1c26466325d0b96769f15ce43c1b5 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Sun, 6 Aug 2023 17:10:05 +0000 Subject: [PATCH] potential reboot --- snippetbox/cmd/web/main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/snippetbox/cmd/web/main.go b/snippetbox/cmd/web/main.go index d86d205..a7d9d57 100644 --- a/snippetbox/cmd/web/main.go +++ b/snippetbox/cmd/web/main.go @@ -1,18 +1,23 @@ package main import ( + "flag" "log" "net/http" + "os" ) func main() { + addr := flag.String("addr", ":4000", "HTTP network address") + flag.Parse() + infoLog := log.New(os.Stdout, "INFO\t", log.Ldate|log.Ltime) mux := http.NewServeMux() fileServer := http.FileServer(http.Dir("./ui/static/")) mux.Handle("/static/", http.StripPrefix("/static", fileServer)) mux.HandleFunc("/", home) mux.HandleFunc("/snippet/view", snippetView) mux.HandleFunc("/snippet/create", snippetCreate) - log.Print("Starting server on :4000") - err := http.ListenAndServe(":4000", mux) + log.Printf("Starting server on %s", *addr) + err := http.ListenAndServe(*addr, mux) log.Fatal(err) }