packagemain
import"net/http"
funcSayHello(whttp.ResponseWriter,r*http.Request){
w.Write([]byte("hello"))
}
funcmain(){
http.HandleFunc("/hello",SayHello())
http.ListenAndServe(":1234",nil)
}
listenAndServer进行端口的监听
handlefunc进行注册路径的处理函数
处理函数为sayhello
时间: 2024-11-24 18:42:13