change(backend): serve static file from /static and serve index.html for /
This commit is contained in:
parent
7a32a44877
commit
07e3c29851
1 changed files with 8 additions and 14 deletions
8
main.go
8
main.go
|
@ -1,7 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
@ -10,8 +9,6 @@ var currentConfig config
|
|||
|
||||
func handleRequest(w http.ResponseWriter, r *http.Request) {
|
||||
path := r.URL.Path
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
if path == "/" {
|
||||
http.ServeFile(w, r, "./static/index.html")
|
||||
|
||||
|
@ -21,9 +18,6 @@ func handleRequest(w http.ResponseWriter, r *http.Request) {
|
|||
} else {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
}
|
||||
case "POST":
|
||||
fmt.Println("Post!")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,6 +28,6 @@ func main() {
|
|||
|
||||
err := http.ListenAndServe(listen, nil)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue