Redirect / -> /split (insert route at index 0 to override Gradio's /)
Browse files
app.py
CHANGED
|
@@ -112,13 +112,14 @@ def _attach_split_view() -> None:
|
|
| 112 |
"""`/split` endpoint — Open WebUI iframe + 참고자료 polling 분할 레이아웃.
|
| 113 |
|
| 114 |
KPAA local 의 _SPLIT_HTML 을 그대로 재사용하되 iframe src 만 UI Space URL 로
|
| 115 |
-
교체. /
|
|
|
|
| 116 |
"""
|
| 117 |
-
from fastapi.responses import HTMLResponse
|
|
|
|
| 118 |
|
| 119 |
from kpaa.server import _SPLIT_HTML
|
| 120 |
|
| 121 |
-
# Local 은 localhost:8080 (Open WebUI), HF 에서는 UI Space URL.
|
| 122 |
UI_SPACE_URL = "https://scvcoder-korean-privacy-ai-assistant.hf.space"
|
| 123 |
hf_html = _SPLIT_HTML.replace(
|
| 124 |
'src="http://localhost:8080/"',
|
|
@@ -129,9 +130,16 @@ def _attach_split_view() -> None:
|
|
| 129 |
async def split_view() -> str:
|
| 130 |
return hf_html
|
| 131 |
|
| 132 |
-
#
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
|
| 137 |
if __name__ == "__main__":
|
|
|
|
| 112 |
"""`/split` endpoint — Open WebUI iframe + 참고자료 polling 분할 레이아웃.
|
| 113 |
|
| 114 |
KPAA local 의 _SPLIT_HTML 을 그대로 재사용하되 iframe src 만 UI Space URL 로
|
| 115 |
+
교체. / 접속 시 /split 으로 리다이렉트 — Gradio 가 / 를 점유하지만 우리
|
| 116 |
+
redirect 라우트를 routes 리스트 *앞* 에 끼워넣어 우선권 획득.
|
| 117 |
"""
|
| 118 |
+
from fastapi.responses import HTMLResponse, RedirectResponse
|
| 119 |
+
from fastapi.routing import APIRoute
|
| 120 |
|
| 121 |
from kpaa.server import _SPLIT_HTML
|
| 122 |
|
|
|
|
| 123 |
UI_SPACE_URL = "https://scvcoder-korean-privacy-ai-assistant.hf.space"
|
| 124 |
hf_html = _SPLIT_HTML.replace(
|
| 125 |
'src="http://localhost:8080/"',
|
|
|
|
| 130 |
async def split_view() -> str:
|
| 131 |
return hf_html
|
| 132 |
|
| 133 |
+
# / → /split 리다이렉트 (Gradio 보다 우선)
|
| 134 |
+
async def _root_redirect():
|
| 135 |
+
return RedirectResponse(url="/split", status_code=302)
|
| 136 |
+
|
| 137 |
+
demo.app.routes.insert(
|
| 138 |
+
0,
|
| 139 |
+
APIRoute("/", _root_redirect, methods=["GET"], include_in_schema=False),
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
print(f"[kpaa-backend] /split + / redirect added (UI iframe -> {UI_SPACE_URL})", flush=True)
|
| 143 |
|
| 144 |
|
| 145 |
if __name__ == "__main__":
|