Serve split HTML directly at / (no redirect) — overrides Gradio's /
Browse files
app.py
CHANGED
|
@@ -126,20 +126,25 @@ def _attach_split_view() -> None:
|
|
| 126 |
f'src="{UI_SPACE_URL}"',
|
| 127 |
)
|
| 128 |
|
| 129 |
-
|
| 130 |
-
async def
|
| 131 |
-
return hf_html
|
| 132 |
|
| 133 |
-
# /
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
|
| 136 |
|
|
|
|
|
|
|
|
|
|
| 137 |
demo.app.routes.insert(
|
| 138 |
0,
|
| 139 |
-
APIRoute("/",
|
| 140 |
)
|
| 141 |
|
| 142 |
-
print(f"[kpaa-backend] /
|
| 143 |
|
| 144 |
|
| 145 |
if __name__ == "__main__":
|
|
|
|
| 126 |
f'src="{UI_SPACE_URL}"',
|
| 127 |
)
|
| 128 |
|
| 129 |
+
# 핸들러 한 개를 /split 와 / 양쪽에 라우팅 — 동일 HTML.
|
| 130 |
+
async def _split_handler():
|
| 131 |
+
return HTMLResponse(hf_html)
|
| 132 |
|
| 133 |
+
# /split — 명시적 별칭 (백워드 호환).
|
| 134 |
+
demo.app.routes.insert(
|
| 135 |
+
0,
|
| 136 |
+
APIRoute("/split", _split_handler, methods=["GET"], include_in_schema=False),
|
| 137 |
+
)
|
| 138 |
|
| 139 |
+
# / — Gradio 의 / 보다 *앞* 에 끼워 넣어 우선권 획득. 사용자가 백엔드 URL 만
|
| 140 |
+
# 입력해도 분할 화면이 바로 보임. Gradio status UI 는 더 이상 노출되지 않지만
|
| 141 |
+
# ZeroGPU 검출은 module-level @spaces.GPU 캐나리로 이미 충족됨.
|
| 142 |
demo.app.routes.insert(
|
| 143 |
0,
|
| 144 |
+
APIRoute("/", _split_handler, methods=["GET"], include_in_schema=False),
|
| 145 |
)
|
| 146 |
|
| 147 |
+
print(f"[kpaa-backend] / and /split serve split HTML (UI iframe -> {UI_SPACE_URL})", flush=True)
|
| 148 |
|
| 149 |
|
| 150 |
if __name__ == "__main__":
|