mirror of
https://github.com/fumiama/go-web-wrapper.git
synced 2026-06-05 00:32:43 +08:00
32 lines
542 B
Go
32 lines
542 B
Go
package main
|
|
|
|
import (
|
|
"archive/zip"
|
|
"bytes"
|
|
_ "embed"
|
|
"fmt"
|
|
"io/fs"
|
|
"net/http"
|
|
)
|
|
|
|
//go:embed dist.zip
|
|
var distzipbytes []byte
|
|
|
|
var distribution = func() http.FileSystem {
|
|
distzip, err := zip.NewReader(bytes.NewReader(distzipbytes), int64(len(distzipbytes)))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return http.FS(fs.FS(distzip))
|
|
}()
|
|
|
|
func init() {
|
|
http.Handle("/", http.FileServer(distribution)) // frontend
|
|
|
|
go func() {
|
|
fmt.Println("server quit for", http.ListenAndServe(Endpoint, nil))
|
|
}()
|
|
|
|
fmt.Println("正在展示:", Endpoint)
|
|
}
|