package main
import (
"log"
"net/http"
)
func main() {
mux := http.NewServeMux()
mux.Handle("/", http.FileServer(http.Dir("")))
mux.HandleFunc("/index", fileHandler)
server := &http.Server{
Addr: ":8080",
Handler: mux,
}
if err := server.ListenAndServe(); err != nil {
log.Fatal(err)
}
}
func fileHandler(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "./ts.html", http.StatusFound)
}
有疑问加站长微信联系(非本文作者)