From 1ccdfaf28a85ea82962b44be18ceb68a6485ff4c Mon Sep 17 00:00:00 2001 From: Odyssey346 Date: Fri, 22 Jul 2022 22:03:34 +0200 Subject: [PATCH] yeah (i hope i can improve this in the future maybe, but right now my logic is not in the right place) Signed-off-by: Odyssey346 --- main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index ed5bd27..e5efbac 100644 --- a/main.go +++ b/main.go @@ -6,24 +6,31 @@ import ( "io" "log" "github.com/ProjectSegfault/segfautilities/otherthings" + "os" ) type StaticThingy struct { Port string } +var pieceof string +var shit bool + func main() { log.Println("[Segfautilities] Starting") otherthings.CheckEnv() + log.Println("[HTTP] Starting server") + pieceof := os.Getenv("SEGFAUTILITIES_PORT") // I hate this tmpl := template.Must(template.ParseFiles("static/index.html")) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { data := StaticThingy{ - Port: "3000", + Port: pieceof, } tmpl.Execute(w, data) }) http.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) { io.WriteString(w, "welcome to hell") }) - http.ListenAndServe(":3000", nil) + log.Println("[HTTP] HTTP server is now running at " + pieceof + "!") + log.Println(http.ListenAndServe(":" + pieceof, nil)) } \ No newline at end of file