[2019.03.08] Go lang (서버 제작)
2019. 3. 8. 11:04ㆍ[공부] 영상/GoLanguage
간단한 웹서버 제작
package main
import "fmt"
import "net/http"
func indexHandler(writer http.ResponseWriter, reader *http.Request) {
fmt.Fprintf(writer, "<h1>index page</h1>")
}
func aboutHandler(writer http.ResponseWriter, reader *http.Request) {
fmt.Fprintf(writer, "<h2>about page</h2>")
}
func main() {
http.HandleFunc("/", indexHandler)
http.HandleFunc("/index", indexHandler)
http.HandleFunc("/about", aboutHandler)
http.ListenAndServe(":8000", nil)
}
http://localhost:8000/
http://localhost:8000/index
http://localhost:8000/about
'[공부] 영상 > GoLanguage' 카테고리의 다른 글
[2019.03.08] Go lang (Html template) (0) | 2019.03.08 |
---|---|
[2019.03.08] Go lang (Map, Defer, Panic, Recover) (0) | 2019.03.08 |
[2019.03.08] Go lang (Struct) (0) | 2019.03.08 |
[2019.03.08] Go lang (기본 - 타입, 함수, 포인터, 루프) (0) | 2019.03.08 |
[2019.03.08] Go lang (Intro) (0) | 2019.03.08 |