Go と Gorilla Mux を使用しています。
これは私の webserver.go ファイルです
package main
import (
"log"
"net/http"
"github.com/gorilla/mux"
)
func HomeHandler(rw http.ResponseWriter, r *http.Request) {
http.ServeFile(rw, r, "index.html")
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/", HomeHandler)
http.Handle("/", r)
log.Println("Server running on :8080")
err := http.ListenAndServe(":8080", r)
if err != nil {
log.Printf("Error: %s\n", err.Error())
}
}
webserver.go ファイルと同じフォルダーに index.html ファイルがあります。
/ - ここに index.html があります
/css - すべての CSS ファイル
/images - すべての画像、リソース ファイル
上記のコードを使用して index.html ファイルをロードすることはできましたが、CSS ファイルと画像をロードしていないようです。
私が持っている index.html ファイル内。
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/animate-custom.css" />
それで、cssファイルを見つける必要がありますか、それとも「Go」がcssと画像フォルダーを見つけることができることを確認する必要がありますか? どのように?