yt-remote-control/main.go

33 lines
592 B
Go
Raw Permalink Normal View History

2024-09-15 14:16:45 +02:00
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)
}