scvcoder commited on
Commit
5c07da5
·
verified ·
1 Parent(s): 3264ba1

Serve split HTML directly at / (no redirect) — overrides Gradio's /

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -126,20 +126,25 @@ def _attach_split_view() -> None:
126
  f'src="{UI_SPACE_URL}"',
127
  )
128
 
129
- @demo.app.get("/split", response_class=HTMLResponse)
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__":
 
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__":