mirror of
https://github.com/Macrame-App/Macrame
synced 2025-12-29 07:19:26 +00:00
Initial commit
This commit is contained in:
commit
d2d9aca35c
35 changed files with 4310 additions and 0 deletions
38
be/main.go
Normal file
38
be/main.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"mime"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
// log.Println(r.URL.Path)
|
||||
|
||||
file := "../public" + r.URL.Path
|
||||
|
||||
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")
|
||||
// }
|
||||
} else {
|
||||
contentType := mime.TypeByExtension(filepath.Ext(file))
|
||||
if contentType != "" {
|
||||
w.Header().Set("Content-Type", contentType)
|
||||
}
|
||||
}
|
||||
|
||||
log.Println(file)
|
||||
log.Println("-------------")
|
||||
http.ServeFile(w, r, file)
|
||||
})
|
||||
|
||||
log.Fatal(http.ListenAndServe(":6970", nil))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue