Add .html suffix to html pages, updated webui.go to search for them correctly
This commit is contained in:
@@ -2,6 +2,7 @@ package httpserver
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func RegisterWebui() {
|
||||
@@ -13,6 +14,24 @@ func RegisterWebui() {
|
||||
http.NotFound(w, r)
|
||||
})
|
||||
|
||||
fs := http.FileServer(http.Dir("web"))
|
||||
http.Handle("/web/", http.StripPrefix("/web/", fs))
|
||||
fs := http.Dir("web")
|
||||
|
||||
http.Handle("/web/", http.StripPrefix("/web/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
path := r.URL.Path
|
||||
f, err := fs.Open(path)
|
||||
if err != nil {
|
||||
//file doesn't exist, try adding .html, probably a bad idea
|
||||
htmlPath := path + ".html"
|
||||
f, err = fs.Open(htmlPath)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
http.ServeFile(w, r, filepath.Join("web", htmlPath))
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
http.ServeFile(w, r, filepath.Join("web", path))
|
||||
})))
|
||||
}
|
||||
|
||||
1
web/js/lib/search_params.js
Normal file
1
web/js/lib/search_params.js
Normal file
@@ -0,0 +1 @@
|
||||
export const url_params = new URLSearchParams(window.location.search)
|
||||
@@ -1,3 +1,4 @@
|
||||
import * as lib from '/web/js/api/libraries.js';
|
||||
import { url_params } from '/web/js/lib/search_params.js'
|
||||
|
||||
console.log(await lib.ls("lib1", "/"))
|
||||
console.log(await lib.ls(url_params.get("lib"), url_params.get("path")))
|
||||
Reference in New Issue
Block a user