Created
December 5, 2018 09:37
-
-
Save sonyarianto/92a3d645af2370762cd749b2093da7d3 to your computer and use it in GitHub Desktop.
Hello World on web 2
This file contains 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 ( | |
"io" | |
"log" | |
"net/http" | |
) | |
func Default(w http.ResponseWriter, r *http.Request) { | |
if r.URL.Path != "/" { | |
http.NotFound(w, r) | |
return | |
} | |
w.Header().Set("Content-Type", "text/html; charset=utf-8") | |
io.WriteString(w, "<h1>hello, world</h1>") | |
} | |
func main() { | |
http.HandleFunc("/", Default) | |
log.Fatal(http.ListenAndServe(":3000", nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment