liumaolin
commited on
Commit
·
f7b034a
1
Parent(s):
86dbbe1
Update static file routing and root endpoint for frontend integration
Browse files- Change static file mount point to `/app` with HTML support.
- Replace root endpoint's `FileResponse` with `RedirectResponse` to `/app/`.
- Update server availability check URL in Electron app to align with new routing.
- electron-app/main.js +2 -2
- src/voice_dialogue/api/app.py +3 -4
electron-app/main.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:673ca7b004730c2da12f2d88ea33a5f4d275e91974022ecaa55af9d311352c82
|
| 3 |
+
size 6447
|
src/voice_dialogue/api/app.py
CHANGED
|
@@ -3,7 +3,7 @@ from typing import Dict, Any
|
|
| 3 |
|
| 4 |
from fastapi import FastAPI, HTTPException, APIRouter
|
| 5 |
from fastapi.middleware.cors import CORSMiddleware
|
| 6 |
-
from fastapi.responses import
|
| 7 |
from fastapi.staticfiles import StaticFiles
|
| 8 |
|
| 9 |
from voice_dialogue.config.paths import FRONTEND_ASSETS_PATH
|
|
@@ -51,7 +51,7 @@ def create_app() -> FastAPI:
|
|
| 51 |
_register_exception_handlers(app)
|
| 52 |
|
| 53 |
# 添加静态文件路由
|
| 54 |
-
app.mount("/", StaticFiles(directory=FRONTEND_ASSETS_PATH.as_posix()), name="static")
|
| 55 |
|
| 56 |
return app
|
| 57 |
|
|
@@ -76,8 +76,7 @@ def _register_health_routes(app: FastAPI):
|
|
| 76 |
|
| 77 |
@app.get("/")
|
| 78 |
async def root():
|
| 79 |
-
|
| 80 |
-
return FileResponse(index_file)
|
| 81 |
|
| 82 |
|
| 83 |
def _get_service_status(app_state: Dict[str, Any]) -> dict:
|
|
|
|
| 3 |
|
| 4 |
from fastapi import FastAPI, HTTPException, APIRouter
|
| 5 |
from fastapi.middleware.cors import CORSMiddleware
|
| 6 |
+
from fastapi.responses import RedirectResponse
|
| 7 |
from fastapi.staticfiles import StaticFiles
|
| 8 |
|
| 9 |
from voice_dialogue.config.paths import FRONTEND_ASSETS_PATH
|
|
|
|
| 51 |
_register_exception_handlers(app)
|
| 52 |
|
| 53 |
# 添加静态文件路由
|
| 54 |
+
app.mount("/app", StaticFiles(directory=FRONTEND_ASSETS_PATH.as_posix(), html=True), name="static")
|
| 55 |
|
| 56 |
return app
|
| 57 |
|
|
|
|
| 76 |
|
| 77 |
@app.get("/")
|
| 78 |
async def root():
|
| 79 |
+
return RedirectResponse(url='/app/')
|
|
|
|
| 80 |
|
| 81 |
|
| 82 |
def _get_service_status(app_state: Dict[str, Any]) -> dict:
|