goCake/main.go

31 lines
711 B
Go
Raw Normal View History

2020-11-08 16:00:33 +00:00
package main
import (
"html/template"
"net/http"
)
func main() {
http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("css"))))
// when navigating to /home it should serve the home page
2020-11-15 19:46:32 +00:00
http.HandleFunc("/", Home)
2020-11-22 17:33:27 +00:00
http.HandleFunc("/rewards", Rewards)
http.HandleFunc("/kraken", Rewards)
http.ListenAndServe(":8080", nil)
2020-11-08 16:00:33 +00:00
}
func render(w http.ResponseWriter, tmpl string, data interface{}) {
//parse the template file held in the templates folder
t, err := template.ParseFiles("templates/"+tmpl, "templates/includes.html")
if err != nil {
panic(err)
}
// render the website and pass data to the templating engine
err = t.Execute(w, data)
if err != nil {
panic(err)
}
}