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:
@@ -7,6 +7,7 @@ from fastapi import (
|
|||||||
HTTPException,
|
HTTPException,
|
||||||
Depends,
|
Depends,
|
||||||
)
|
)
|
||||||
|
from fastapi.responses import FileResponse
|
||||||
import asyncio
|
import asyncio
|
||||||
import threading
|
import threading
|
||||||
import os
|
import os
|
||||||
@@ -875,7 +876,11 @@ def create_app(args):
|
|||||||
# Webui mount webui/index.html
|
# Webui mount webui/index.html
|
||||||
static_dir = Path(__file__).parent / "webui"
|
static_dir = Path(__file__).parent / "webui"
|
||||||
static_dir.mkdir(exist_ok=True)
|
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
|
return app
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user