Now actually serve the correct page
This commit is contained in:
parent
1cf6fd7e46
commit
f6742dead4
1 changed files with 33 additions and 0 deletions
33
main.go
Normal file
33
main.go
Normal file
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue