mirror of
https://github.com/adanrsantos/ThePlaceHolders.git
synced 2024-12-16 14:20:39 -06:00
32 lines
584 B
Go
32 lines
584 B
Go
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")
|
|
}
|
|
}
|