Created
September 11, 2016 03:07
-
-
Save asit-dhal/ae060c1613f5d1f5f6eca0089ea21e5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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