feat: allow setting of path to load static files from

This commit is contained in:
ChrisOboe 2025-01-03 16:05:37 +01:00
parent 17ae37b590
commit 1d7f3349ba
No known key found for this signature in database

10
main.go
View file

@ -38,6 +38,7 @@ var (
visionLlmModel = os.Getenv("VISION_LLM_MODEL")
logLevel = strings.ToLower(os.Getenv("LOG_LEVEL"))
listenInterface = os.Getenv("LISTEN_INTERFACE")
webuiPath = os.Getenv("WEBUI_PATH")
// Templates
titleTemplate *template.Template
@ -188,13 +189,16 @@ func main() {
})
}
if webuiPath == "" {
webuiPath = "./web-app/dist"
}
// Serve static files for the frontend under /assets
router.StaticFS("/assets", gin.Dir("./web-app/dist/assets", true))
router.StaticFile("/vite.svg", "./web-app/dist/vite.svg")
router.StaticFS("/assets", gin.Dir(webuiPath+"/assets", true))
router.StaticFile("/vite.svg", webuiPath+"/vite.svg")
// Catch-all route for serving the frontend
router.NoRoute(func(c *gin.Context) {
c.File("./web-app/dist/index.html")
c.File(webuiPath + "/index.html")
})
// Start OCR worker pool