我在使用Go制造的服務(wù)器上獲取index.html,main.js,style.css等文件時(shí)遇到麻煩。我的html文件在本地文件上與javascript和css一起正常工作,但是我無法使其在服務(wù)器上工作。我已經(jīng)嘗試在我的代碼中進(jìn)行此操作,但是它僅啟動html文件,并且在控制臺中列出了javascript,css,jquer,字體,就像找不到該頁面(找不到404頁面)一樣。r := mux.NewRouter()r.Handle("/", http.FileServer(http.Dir("./static")))r.HandleFunc("/events", eventHandler) //Ignore thisr.NotFoundHandler = http.HandlerFunc(notFound) //This is just a custom 404.// Create and start HTTP server.s := &http.Server{ Handler: r, Addr: config.Address,}我的問題是:沒有Node.js,是否有可能做到這一點(diǎn)。是否有任何選項(xiàng)可以在HTML中顯示我所有的JavaScript文件和CSS。我真的不想讓Node復(fù)雜化。
是否可以將html,css,js,…添加到Go服務(wù)器?
墨色風(fēng)雨
2021-04-09 18:19:15