1234567891011121314151617181920 |
- package main
- import (
- "net/http"
- "log"
- )
- func main() {
- http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- data, err := Asset("assets/index.html") // 访问打包的文件
- if err != nil {
- http.Error(w, "File not found", http.StatusNotFound)
- return
- }
- w.Write(data)
- })
- log.Println("Listening on :8080")
- log.Fatal(http.ListenAndServe(":8080", nil))
- }
|