From 3b1d876d1350b64ae0c45e68b102af3fdedb0bb2 Mon Sep 17 00:00:00 2001 From: Christoph Ruckstetter Date: Mon, 6 Jan 2025 09:29:07 +0000 Subject: [PATCH] Allow setting of path to read static files from (#58) * feat: allow setting of path to load static files from * Describe WEBUI_PATH setting in readme --------- Co-authored-by: Icereed --- README.md | 2 ++ main.go | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d0dbb6b..4276357 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ services: VISION_LLM_MODEL: 'minicpm-v' # Optional (for OCR) - minicpm-v, for example for ollama, gpt-4o for openai LOG_LEVEL: 'info' # Optional or 'debug', 'warn', 'error' LISTEN_INTERFACE: '127.0.0.1:8080' # Optional, default is ':8080' + WEBUI_PATH: '/usr/share/paperless-gpt/webui' # Optional, default is './web-app/dist' volumes: - ./prompts:/app/prompts # Mount the prompts directory ports: @@ -149,6 +150,7 @@ If you prefer to run the application manually: | `VISION_LLM_MODEL` | The model name to use for OCR (e.g., `minicpm-v`). | No | | `LOG_LEVEL` | The log level for the application (`info`, `debug`, `warn`, `error`). Default is `info`. | No | | `LISTEN_INTERFACE` | The interface paperless-gpt listens to. Default is `:8080` | No | +| `WEBUI_PATH` | The path to load static content from. Default is `./web-app/dist` | No | | `AUTO_GENERATE_TITLE` | Enable/disable title generation when automatically applying suggestions with `paperless-gpt-auto`. Default is `true` | No | | `AUTO_GENERATE_TAGS` | Enable/disable tag generation when automatically applying suggestions with `paperless-gpt-auto`. Default is `true` | No | diff --git a/main.go b/main.go index 56662be..91c86a7 100644 --- a/main.go +++ b/main.go @@ -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") autoGenerateTitle = os.Getenv("AUTO_GENERATE_TITLE") autoGenerateTags = os.Getenv("AUTO_GENERATE_TAGS") @@ -190,13 +191,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