33 lines
592 B
Go
33 lines
592 B
Go
package main
|
|
|
|
import (
|
|
"embed"
|
|
_ "embed"
|
|
"flag"
|
|
"fmt"
|
|
"io/fs"
|
|
"net/http"
|
|
)
|
|
|
|
//go:embed static
|
|
var StaticFilesDir embed.FS
|
|
|
|
var ( // flags
|
|
FlagInterface = flag.String("i", "", "network interface")
|
|
FlagPort = flag.Uint("p", 8080, "network port")
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
|
|
staticFiles, err := fs.Sub(StaticFilesDir, "static")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
http.Handle("/api/", http.StripPrefix("/api", http.HandlerFunc(ProxyRequest)))
|
|
http.Handle("/", http.FileServer(http.FS(staticFiles)))
|
|
|
|
http.ListenAndServe(fmt.Sprintf("%s:%d", *FlagInterface, *FlagPort), nil)
|
|
}
|