Enhance webui mounting with root endpoint and directory check.
- Added FileResponse for webui root endpoint - Enabled directory check in StaticFiles mount - Improved webui static file handling - Ensured webui directory existence - Simplified webui access with root endpoint
This commit is contained in:
parent
36de7e3197
commit
3c080a9ebf
1 changed files with 6 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ from fastapi import (
|
|||
HTTPException,
|
||||
Depends,
|
||||
)
|
||||
from fastapi.responses import FileResponse
|
||||
import asyncio
|
||||
import threading
|
||||
import os
|
||||
|
|
@ -875,7 +876,11 @@ def create_app(args):
|
|||
# Webui mount webui/index.html
|
||||
static_dir = Path(__file__).parent / "webui"
|
||||
static_dir.mkdir(exist_ok=True)
|
||||
app.mount("/webui", StaticFiles(directory=static_dir, html=True), name="webui")
|
||||
app.mount("/webui", StaticFiles(directory=static_dir, html=True, check_dir=True), name="webui")
|
||||
|
||||
@app.get("/webui/")
|
||||
async def webui_root():
|
||||
return FileResponse(static_dir / "index.html")
|
||||
|
||||
return app
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue