package main import (
"io/ioutil"
"log"
"net/http"
) func main() {
http.HandleFunc("/", ShowIndex)
log.Fatal(http.ListenAndServe("localhost:8000", nil))
} func ShowIndex(w http.ResponseWriter, r *http.Request) {
content, _ := ioutil.ReadFile("./index.html")
w.Write(content)
}
//在浏览器上输入 localhost:8000 就可以显示 index.html