Created
February 19, 2015 18:51
-
-
Save keizo042/c469fc1b016568ba6946 to your computer and use it in GitHub Desktop.
てきとーなWebapp
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 | |
/* | |
git clone して | |
go build webapp.go | |
./webapp | |
としたあと | |
http://localhost:8080 | |
にアクセス | |
*/ | |
import ( | |
"fmt" | |
"net/http" | |
) | |
func main() { | |
http.HandleFunc("/",handleIndex) | |
http.HandleFunc("/ans",handleAns) | |
http.HandleFunc("/ans2",handleAns2) | |
http.ListenAndServe(":8080",nil) | |
} | |
func handleIndex(r http.ResponseWriter, req *http.Request) { | |
index := ` | |
<html> | |
<body> | |
<h1> プログラミングは好きですか? </h1> | |
<a href="/ans">はい</a> | |
<br> | |
<a href="/ans2">いいえ</a> | |
</body> | |
</html> | |
` | |
fmt.Fprintln(r,index) | |
} | |
func handleAns(r http.ResponseWriter, req *http.Request) { | |
index := ` | |
<html> | |
<body> | |
<h1> イイネッ </h1> | |
</body> | |
</html> | |
` | |
fmt.Fprintln(r,index) | |
} | |
func handleAns2(r http.ResponseWriter, req *http.Request) { | |
index := ` | |
<html> | |
<body> | |
<h1> BBBOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO </h1> | |
</body> | |
</html> | |
` | |
fmt.Fprintln(r,index) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment