mirror of
https://github.com/fumiama/go-web-wrapper.git
synced 2026-06-09 04:29:40 +08:00
init
This commit is contained in:
31
dist.go
Normal file
31
dist.go
Normal file
@@ -0,0 +1,31 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user