Browse Source

feat: added initial webserver

main
Björn Kalkbrenner 4 months ago
parent
commit
85af45bf66
  1. 3
      src/server/go.mod
  2. 32
      src/server/server.go

3
src/server/go.mod

@ -0,0 +1,3 @@
module teruna.dev/radio.de/cc-top100
go 1.16

32
src/server/server.go

@ -0,0 +1,32 @@
package main
import (
"fmt"
"log"
"net/http"
)
const LISTEN_ADDR string = "80"
const STATIC_PATH string = "src/web"
func main() {
http.HandleFunc("/update", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotImplemented)
w.Write([]byte("501 - Not implemented yet"))
})
http.HandleFunc("/rank", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, "{}")
})
fs := http.FileServer(http.Dir(STATIC_PATH))
http.Handle("/", fs)
log.Printf("Listening on %s\n", LISTEN_ADDR)
err := http.ListenAndServe(":80", nil)
if err != nil {
log.Fatal(err)
}
}
Loading…
Cancel
Save