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
posted @ 2022-04-26 22:09  ty1539  阅读(31)  评论(0)    收藏  举报