Created
June 10, 2012 19:48
-
-
Save ncweinhold/2907108 to your computer and use it in GitHub Desktop.
Dabbling 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" | |
"fmt" | |
) | |
func main() { | |
http.HandleFunc("/", indexHandler) | |
http.HandleFunc("/about", aboutHandler) | |
http.ListenAndServe(":8080", nil) | |
} | |
func indexHandler(w http.ResponseWriter, req *http.Request) { | |
fmt.Fprint(w, indexPage) | |
} | |
func aboutHandler(w http.ResponseWriter, req *http.Request) { | |
fmt.Fprint(w, aboutPage) | |
} | |
const indexPage = ` | |
<html> | |
<head> | |
<title>Simple Web App With Go</title> | |
</head> | |
<body> | |
<h1>Simple Web App</h1> | |
<p>This is a simple web application built using Go.</p> | |
</body> | |
</html> | |
` | |
const aboutPage = ` | |
<html> | |
<head> | |
<title>About</title> | |
</head> | |
<body> | |
<h1>About</h1> | |
<p>This is a simple web application created using Go.</p> | |
</body> | |
</html> | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment