package main import ( "fmt" "net/http" ) const ADDRESS = "127.0.0.1" const PORT = "8080" func get_canvas(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "test data") } func main() { // Host static files static_files := http.FileServer(http.Dir("static/")) http.Handle("/", static_files) // Response generated by code http.HandleFunc("/get-canvas", get_canvas) // Start web server at 127.0.0.1:8080 e := http.ListenAndServe(ADDRESS+":"+PORT, nil) // Print any errors if e != nil { fmt.Println(e) } else { fmt.Println("Started server successfully") } }