Skip to content

Instantly share code, notes, and snippets.

@1o1brian
Created September 6, 2012 16:14
Show Gist options
  • Save 1o1brian/3658007 to your computer and use it in GitHub Desktop.
Save 1o1brian/3658007 to your computer and use it in GitHub Desktop.
http with go
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