diff --git a/main.go b/main.go new file mode 100644 index 0000000..b130ecb --- /dev/null +++ b/main.go @@ -0,0 +1,33 @@ +package main + +import ( + "html/template" + "log" + "net/http" + "os" +) + +func main() { + port := os.Getenv("PORT") + if port == "" { + port = "8080" + log.Printf("Defaulting to port %s \n", port) + } + + http.HandleFunc("/", handleRoot) + if err := http.ListenAndServe(":"+port, nil); err != nil { + log.Fatal(err) + } +} + +func handleRoot(w http.ResponseWriter, r *http.Request) { + tmpl, err := template.ParseFiles("templates/index.html") + if err != nil { + http.Error(w, "Couldn't parse template file", http.StatusInternalServerError) + return + } + err = tmpl.Execute(w, "Nothing lol") + if err != nil { + http.Error(w, "Failed to execute template", http.StatusInternalServerError) + } +}