diff --git a/be/main.go b/be/main.go index 7efa6c1..ac54cc9 100644 --- a/be/main.go +++ b/be/main.go @@ -9,29 +9,25 @@ import ( func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - // log.Println(r.URL.Path) - file := "../public" + r.URL.Path + file := "../public" // base directory if r.URL.Path == "/" { - file = "../public/index.html" - // } else if strings.HasSuffix(r.URL.Path, ".js") { - // log.Println("js") - // w.Header().Set("Content-Type", "application/javascript") - // } else if strings.HasSuffix(r.URL.Path, ".css") { - // log.Println("css") - // w.Header().Set("Content-Type", "text/css") - // } + file = file + "/index.html" // default } else { - contentType := mime.TypeByExtension(filepath.Ext(file)) - if contentType != "" { - w.Header().Set("Content-Type", contentType) - } + file = file + r.URL.Path // request + } + + contentType := mime.TypeByExtension(filepath.Ext(file)) // get content type + + if contentType != "" { + w.Header().Set("Content-Type", contentType) // set content type header } log.Println(file) log.Println("-------------") - http.ServeFile(w, r, file) + + http.ServeFile(w, r, file) // serve file }) log.Fatal(http.ListenAndServe(":6970", nil)) diff --git a/be/tmp/main.exe b/be/tmp/main.exe index 0d55388..7254eb6 100644 Binary files a/be/tmp/main.exe and b/be/tmp/main.exe differ