Server now returns HTML and can pass back/forth data
This commit is contained in:
5
serve.go
5
serve.go
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user