第15章 15.2-http服务器

2020-01-25  本文已影响0人  yezide
package main

import "fmt"
import "net/http"

func HttpHelloGo(w http.ResponseWriter, req *http.Request) {
    fmt.Fprintf(w, "Hello,"+req.URL.Path[1:])
}

func main() {
    fmt.Println("开始启动http服务器")
    http.HandleFunc("/hellogo", HttpHelloGo)
    http.ListenAndServe(":8081", nil)
}
上一篇下一篇

猜你喜欢

热点阅读