go-examples/tpl-ex2/main.go
2017-07-26 20:34:08 +02:00

21 lines
347 B
Go

package main
import (
"html/template"
"net/http"
)
func main() {
tpl, err := template.ParseFiles("tpl.html")
if err != nil {
panic(err)
}
http.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
err = tpl.ExecuteTemplate(res, "tpl.html", req)
if err != nil {
panic(err)
}
})
http.ListenAndServe(":9000", nil)
}