【问题标题】:Go web server 404 page not found未找到 Go Web 服务器 404 页面
【发布时间】:2019-12-08 03:37:21
【问题描述】:

我是 Web 程序集的新手

我在Hello_WebAssembly目录下的服务器index.htmlwasm_exec.jsmain.wasm写了一个web.go

然后我在终端go run web.go

然后我去 localhost:8080 它报告404 page not found

我按照https://github.com/golang/go/wiki/WebAssembly的指示进行操作

这是我的web.go 代码

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

【问题讨论】:

    标签: go webserver webassembly


    【解决方案1】:

    我假设您的项目名为Hello_WebAssembly,并且您正在从文件夹中运行go run 命令。

    如果是这种情况,那么您的 http.Dirinvocation 应该是 http.Dir("."),因为您想从当前目录(项目)提供资源。

    【讨论】:

      猜你喜欢
      • 2016-05-19
      • 2014-01-22
      • 2021-02-12
      • 1970-01-01
      • 2016-03-17
      • 2015-07-21
      • 1970-01-01
      • 2016-07-15
      • 2013-01-28
      相关资源
      最近更新 更多