Created
September 6, 2012 16:14
-
-
Save 1o1brian/3658007 to your computer and use it in GitHub Desktop.
http with go
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" ; "io") | |
func hello(res http.ResponseWriter, req *http.Request) { | |
res.Header().Set( | |
"Content-Type", | |
"text/html", | |
) | |
io.WriteString( | |
res, | |
`<doctype html> | |
<html> | |
<head> | |
<title>Hello World</title> | |
</head> | |
<body> | |
Hello World! | |
</body> | |
</html>`, | |
) | |
} | |
func main() { | |
http.HandleFunc("/hello", hello) | |
http.ListenAndServe(":9000", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment