Skip to content

Instantly share code, notes, and snippets.

@asit-dhal
Created September 11, 2016 03:07
Show Gist options
  • Save asit-dhal/ae060c1613f5d1f5f6eca0089ea21e5c to your computer and use it in GitHub Desktop.
Save asit-dhal/ae060c1613f5d1f5f6eca0089ea21e5c to your computer and use it in GitHub Desktop.
package main
import (
"net/http"
"html/template"
)
func handler(w http.ResponseWriter, r *http.Request) {
t, _ := template.ParseFiles("view.html") //setp 1
t.Execute(w, "Hello World!") //step 2
}
func main() {
server := http.Server{
Addr: "127.0.0.1:8080",
}
http.HandleFunc("/view", handler)
server.ListenAndServe()
}
<html>
<head>
<title>First Program</title>
</head>
<body>
{{ . }}
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment