import (
"net/http"
)
func main() {
http.Handle("/", http.FileServer(http.Dir("static")))
http.ListenAndServe(":8080", nil)
}
我導航到本地主機:8080 /並得到404錯誤。我究竟做錯了什麼?含main.go
404當試圖從文件系統提供文件
main.go
static
|- index.html
而且:
您希望從GET /?中得到什麼? – Volker
我的Index.html在靜態文件夾中 – Dante
'server.RegisterHandlers()'做了什麼?假如你有一個名爲「static」的文件夾,沒有它,代碼應該可以正常工作。 – ANisus