Server now returns HTML and can pass back/forth data

This commit is contained in:
Kevin
2017-09-18 15:10:01 -04:00
parent 6b56699280
commit 04279d77f0
5 changed files with 223 additions and 1 deletions

View File

@@ -38,12 +38,15 @@ func index(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(options)
} else if r.Method == "GET" {
fmt.Fprintf(w, "Hello go!") // To be updated
http.ServeFile(w, r, "./templates/index.html")
}
}
func main() {
// Serve index.html
http.HandleFunc("/", index)
// Serve all the assets
http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("./templates/assets"))))
http.ListenAndServe(":8080", nil)
}