You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
xubuntu 18.04
go env Output
$ go env
export PATH=$PATH:/usr/local/go/bin
What did you do?
I write a simple web server by golang. I use gorilla package and i have a problem to show html body of web page. I have an html code instead of web page/ I tried mozilla and chrome (same result)
package main
import (
"html/template"
"net/http"
"github.com/gorilla/mux"
)
func main() {
router := mux.NewRouter()
router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
tmpl, _ := template.ParseFiles("index.html")
tmpl.Execute(w, nil)
})
http.Handle("/", router)
http.ListenAndServe(":8181", nil)
}
What did you expect to see?
blabla bla bla bla bla bla bla bla bla bla bla
What did you see instead?
I see raw html code:
....
<title>Title</title>
blabla bla bla bla bla bla bla bla bla bla bla
The text was updated successfully, but these errors were encountered:
Setting the Content-Type header explicitly makes it so that browsers (and the HTTP server) don't have to guess what the content type is. Guessing is hard when the content is very short. Glad you figured this out.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?xubuntu 18.04
go env
OutputWhat did you do?
I write a simple web server by golang. I use gorilla package and i have a problem to show html body of web page. I have an html code instead of web page/ I tried mozilla and chrome (same result)
package main
import (
"html/template"
"net/http"
"github.com/gorilla/mux"
)
func main() {
router := mux.NewRouter()
router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
tmpl, _ := template.ParseFiles("index.html")
tmpl.Execute(w, nil)
})
http.Handle("/", router)
http.ListenAndServe(":8181", nil)
}
What did you expect to see?
blabla bla bla bla bla bla bla bla bla bla bla
What did you see instead?
I see raw html code:
<title>Title</title>....
blabla bla bla bla bla bla bla bla bla bla bla
The text was updated successfully, but these errors were encountered: