lmao if you can serve static files

This commit is contained in:
Mark McGranaghan 2012-09-20 13:25:54 -07:00
parent 0939b1ebcd
commit be1e34f0b7

View File

@ -8,8 +8,7 @@ func hello(res http.ResponseWriter, req *http.Request) {
}
func static(res http.ResponseWriter, req *http.Request) {
res.Header().Set("Content-Type", "text/plain")
fmt.Fprintln(res, "Static")
http.ServeFile(res, req, "./01-hello.go")
}
func notFound(res http.ResponseWriter, req *http.Request) {
@ -21,7 +20,7 @@ func notFound(res http.ResponseWriter, req *http.Request) {
func main() {
r := mux.NewRouter()
r.HandleFunc("/", hello)
r.HandleFunc("/favicon.ico", static)
r.HandleFunc("/01-hello.go", static)
r.HandleFunc("/{path:.*}", notFound)
http.ListenAndServe(":5000", r)
}