我跟著用 go 創建了一個基本的 web 應用程序,我創建了一個名為 myApp 的文件夾。在 myApp 中有 main.go 和 public 文件夾(在 public 中有 index.html),這是我在 main.go 中的內容:package mainimport "net/http"import "github.com/russross/blackfriday"func main() { http.HandleFunc("/markdown", GenerateMarkdown) http.Handle("/", http.FileServer(http.Dir("public"))) http.ListenAndServe(":8080", nil)} func GenerateMarkdown(rw http.ResponseWriter, r *http.Request) { markdown := blackfriday.MarkdownCommon([]byte(r.FormValue("body"))) rw.Write(markdown)}我啟動了服務器并轉到http://localhost:8080/但它沒有鏈接到 index.html。誰能解釋為什么它不呈現 index.html 文件。我是 Golang 的新手。
- 1 回答
- 0 關注
- 206 瀏覽
添加回答
舉報
0/150
提交
取消