http-simple-server
package main
import (
"fmt"
"net/http"
)
func Hello(w http.ResponseWriter, r *http.Request) {
fmt.Println("handle hello 123")
fmt.Fprintf(w, "hello 456")
}
func main() {
http.HandleFunc("/", Hello)
err := http.ListenAndServe("0.0.0.0:8888", nil)
if err != nil {
fmt.Println("Http Listen Failed. err:", err)
}
}
在浏览器中输入localhost:8888/ 输出:只是不懂为啥一次请求,输出2个handle hello 123
handle hello 123
handle hello 123
写入自己的博客中才能记得长久

浙公网安备 33010602011771号