I am trying to serve static files which include javascript , css , html files
But it is failing to load all the external files in static
directory
What did I do wrong?
Please help me
router := httprouter.New()
handler := func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
type Page struct {
Title string
}
tp := template.Must(template.ParseFiles("templates/main.html", "templates/base.html"))
tp.ExecuteTemplate(w, "base", &Page{Title: "AAAAA"})
}
router.Handle("GET", "/", handler)
// func (r *Router) Handle(method, path string, handle Handle)
// func (r *Router) Handler(method, path string, handler http.Handler)
// func (r *Router) HandlerFunc(method, path string, handler http.HandlerFunc)
router.Handle("GET", "/aaa", aaa.aaaHandler)
router.Handle("POST", "/aaa_01_submit", aaa.aaa01Submit)
router.Handle("GET", "/aaa_01_run", aaa.aaa01Run)
http.Handle("/static", http.FileServer(http.Dir("static")))
http.ListenAndServe(":8000", router)
Here's my files
/app
/templates
main.html
base.html
/static
/js
files to read...
/lib
/css
main.go