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 <domi@icereed.net>
This commit is contained in:
Christoph Ruckstetter 2025-01-06 09:29:07 +00:00 committed by GitHub
parent 6226b8c898
commit 3b1d876d13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -80,6 +80,7 @@ services:
VISION_LLM_MODEL: 'minicpm-v' # Optional (for OCR) - minicpm-v, for example for ollama, gpt-4o for openai 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' LOG_LEVEL: 'info' # Optional or 'debug', 'warn', 'error'
LISTEN_INTERFACE: '127.0.0.1:8080' # Optional, default is ':8080' 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: volumes:
- ./prompts:/app/prompts # Mount the prompts directory - ./prompts:/app/prompts # Mount the prompts directory
ports: 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 | | `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 | | `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 | | `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_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 | | `AUTO_GENERATE_TAGS` | Enable/disable tag generation when automatically applying suggestions with `paperless-gpt-auto`. Default is `true` | No |

10
main.go
View file

@ -38,6 +38,7 @@ var (
visionLlmModel = os.Getenv("VISION_LLM_MODEL") visionLlmModel = os.Getenv("VISION_LLM_MODEL")
logLevel = strings.ToLower(os.Getenv("LOG_LEVEL")) logLevel = strings.ToLower(os.Getenv("LOG_LEVEL"))
listenInterface = os.Getenv("LISTEN_INTERFACE") listenInterface = os.Getenv("LISTEN_INTERFACE")
webuiPath = os.Getenv("WEBUI_PATH")
autoGenerateTitle = os.Getenv("AUTO_GENERATE_TITLE") autoGenerateTitle = os.Getenv("AUTO_GENERATE_TITLE")
autoGenerateTags = os.Getenv("AUTO_GENERATE_TAGS") 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 // Serve static files for the frontend under /assets
router.StaticFS("/assets", gin.Dir("./web-app/dist/assets", true)) router.StaticFS("/assets", gin.Dir(webuiPath+"/assets", true))
router.StaticFile("/vite.svg", "./web-app/dist/vite.svg") router.StaticFile("/vite.svg", webuiPath+"/vite.svg")
// Catch-all route for serving the frontend // Catch-all route for serving the frontend
router.NoRoute(func(c *gin.Context) { router.NoRoute(func(c *gin.Context) {
c.File("./web-app/dist/index.html") c.File(webuiPath + "/index.html")
}) })
// Start OCR worker pool // Start OCR worker pool