-
-
Save dasgoll/eee2db8a7107655c7d0e9555ce84aa9b 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
### https://hackernoon.com/golang-template-1-bcb690165663 | |
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