main.go 446 B

1234567891011121314151617181920
  1. package main
  2. import (
  3. "net/http"
  4. "log"
  5. )
  6. func main() {
  7. http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
  8. data, err := Asset("assets/index.html") // 访问打包的文件
  9. if err != nil {
  10. http.Error(w, "File not found", http.StatusNotFound)
  11. return
  12. }
  13. w.Write(data)
  14. })
  15. log.Println("Listening on :8080")
  16. log.Fatal(http.ListenAndServe(":8080", nil))
  17. }