Skip to content
Permalink
Browse files

02-Template add templates folder

  • Loading branch information...
bonfy committed Sep 7, 2018
1 parent 1cf55f6 commit cca162aa6510f6d8bf96cb21ef8aed5ea0a1a1a1
Showing with 9 additions and 8 deletions.
  1. +1 −8 main.go
  2. +8 −0 templates/index.html
@@ -13,14 +13,7 @@ type User struct {
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
user := User{Username: "bonfy"}
tpl, _ := template.New("").Parse(`<html>
<head>
<title>Home Page - Bonfy</title>
</head>
<body>
<h1>Hello, {{.Username}}!</h1>
</body>
</html>`)
tpl, _ := template.ParseFiles("templates/index.html")
tpl.Execute(w, &user)
})
http.ListenAndServe(":8888", nil)
@@ -0,0 +1,8 @@
<html>
<head>
<title>Home Page - Bonfy</title>
</head>
<body>
<h1>Hello, {{.Username}}!</h1>
</body>
</html>

0 comments on commit cca162a

Please sign in to comment.
You can’t perform that action at this time.