go-examples/tpl-ex1/main.go

21 lines
363 B
Go
Raw Normal View History

2017-07-26 18:34:08 +00:00
package main
import (
"html/template"
"net/http"
)
func main() {
tpl, err := template.ParseFiles("tpl.html")
if err != nil {
panic(err)
}
http.HandleFunc("/hello/", func(res http.ResponseWriter, req *http.Request) {
err = tpl.ExecuteTemplate(res, "tpl.html", "Hello World")
if err != nil {
panic(err)
}
})
http.ListenAndServe(":9000", nil)
}