找不到Go web服务器404页面
我不熟悉web组装 我写了一个找不到Go web服务器404页面,go,webserver,webassembly,Go,Webserver,Webassembly,我不熟悉web组装 我写了一个web.go到服务器index.htmlwasm\u exec.jsmain.wasm目录下Hello\u WebAssembly 然后我在终端中运行web.go 然后我转到localhost:8080,它报告404未找到页面 我正在按照说明https://github.com/golang/go/wiki/WebAssembly 这是我的web.gocode package main import ( "log" "net/http" ) fu
web.go
到服务器index.html
wasm\u exec.js
main.wasm
目录下Hello\u WebAssembly
然后我在终端中运行web.go
然后我转到localhost:8080,它报告404未找到页面
我正在按照说明https://github.com/golang/go/wiki/WebAssembly
这是我的web.go
code
package main
import (
"log"
"net/http"
)
func main() {
fs := http.FileServer(http.Dir("Hello_WebAssembly"))
http.Handle("/", fs)
log.Println("Listening...")
http.ListenAndServe(":8080", nil)
}
我不知道为什么
希望有人能帮我
提前谢谢
顺便说一下,我的操作系统是win10我假定您的项目名为
Hello\u WebAssembly
,您正在文件夹中运行go run
命令
如果是这种情况,那么您的http.Dir
调用应该是http.Dir(“.”
,因为您希望为当前目录(项目)中的资源提供服务