Separate UI (#1299)

* Add custom_ui_location to serve UI from filesystem
This commit is contained in:
WithoutPants
2021-04-20 17:12:40 +10:00
committed by GitHub
parent 9200f167bf
commit 39512e1452
4 changed files with 37 additions and 0 deletions

View File

@@ -234,9 +234,21 @@ func Start() {
})
}
customUILocation := c.GetCustomUILocation()
// Serve the web app
r.HandleFunc("/*", func(w http.ResponseWriter, r *http.Request) {
ext := path.Ext(r.URL.Path)
if customUILocation != "" {
if r.URL.Path == "index.html" || ext == "" {
r.URL.Path = "/"
}
http.FileServer(http.Dir(customUILocation)).ServeHTTP(w, r)
return
}
if ext == ".html" || ext == "" {
data, _ := uiBox.Find("index.html")
_, _ = w.Write(data)