package main
import (
"html/template"
"net/http"
"strconv"
)
func index(w http.ResponseWriter, r *http.Request) {
// 跳转到主页
t, _ := template.ParseFiles("template/index.html")
_ = t.Execute(w, nil)
}
func main() {
port := 9803
http.HandleFunc("/", index)
http.HandleFunc("/page", index)
_ = http.ListenAndServe(":"+strconv.Itoa(port), nil)
}
http.ResponseWriter 代表返回携带的Response,*http.Request 代表浏览器请求是携带的Request
http.HandleFunc函数要求其中的函数必须包含以上的两个参数