summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-05-06 12:24:54 -0400
committerBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-05-06 12:24:54 -0400
commitf0d2468dc5b37117c7c097703f40e171bd96c377 (patch)
treeb66a6ce2a8215172fc6cdeed5682d6d550a16662 /main.go
parent5c8d644105f7cd95c99577289231d66f6aeda11a (diff)
feat: make port configurable via command-line flag
Diffstat (limited to 'main.go')
-rw-r--r--main.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/main.go b/main.go
index 3512c24..ec799df 100644
--- a/main.go
+++ b/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "flag"
"io"
"log"
"net/http"
@@ -14,15 +15,18 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func main() {
+ port := flag.String("port", "8080", "Default localhost port")
+ flag.Parse()
+
mux := http.NewServeMux()
mux.Handle("/{$}", &handler{})
srv := http.Server{
- Addr: ":8080",
+ Addr: ":" + *port,
Handler: mux,
}
- log.Println("Serving on port 8080...")
+ log.Printf("Serving on port %s...\n", *port)
log.Fatal(srv.ListenAndServe())
}