hirann commited on
Commit
a804462
Β·
verified Β·
1 Parent(s): 2b07b9c

Upload server/main.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. server/main.py +13 -10
server/main.py CHANGED
@@ -238,11 +238,10 @@ the <strong>Live LLM War Room</strong> (Theme #1) on the same page.</p>
238
  """
239
 
240
 
241
- @app.get("/", response_class=PlainTextResponse)
242
- async def root():
243
- """Landing page. Judges land here β†’ see the big 'Launch demo' button."""
244
  from fastapi.responses import HTMLResponse
245
-
246
  return HTMLResponse(_LANDING_HTML)
247
 
248
 
@@ -421,7 +420,11 @@ async def get_logs():
421
  """Returns the captured application logs for troubleshooting."""
422
  return {"logs": log_stream.getvalue()}
423
 
424
- # ─── Mount the Gradio visual demo at /demo ──────────────────────────────────
 
 
 
 
425
 
426
  try:
427
  import gradio as gr
@@ -430,15 +433,15 @@ try:
430
  logger.info("Building Gradio demo UI...")
431
  _demo = build_demo()
432
 
433
- # Mount the Gradio app to the FastAPI app
434
- app = gr.mount_gradio_app(app, _demo, path="/demo")
435
- logger.info("Gradio demo UI mounted at /demo")
436
 
 
437
  @app.get("/launch")
438
- @app.get("/demo-redirect")
439
  async def demo_redirect():
440
  from fastapi.responses import RedirectResponse
441
- return RedirectResponse(url="/demo")
442
 
443
  except Exception as _demo_exc:
444
  logger.error("Failed to mount Gradio demo UI: %s", _demo_exc, exc_info=True)
 
238
  """
239
 
240
 
241
+ @app.get("/landing", response_class=HTMLResponse)
242
+ async def landing_page():
243
+ """Former landing page, now moved to /landing."""
244
  from fastapi.responses import HTMLResponse
 
245
  return HTMLResponse(_LANDING_HTML)
246
 
247
 
 
420
  """Returns the captured application logs for troubleshooting."""
421
  return {"logs": log_stream.getvalue()}
422
 
423
+ # ─── Mount the Gradio visual demo at / ──────────────────────────────────────
424
+ #
425
+ # By mounting at / instead of /demo, the main Space URL on the Hugging Face Hub
426
+ # will load the Gradio UI directly, which is the best experience for judges.
427
+ # API routes (/health, /reset, /step) defined above still take precedence.
428
 
429
  try:
430
  import gradio as gr
 
433
  logger.info("Building Gradio demo UI...")
434
  _demo = build_demo()
435
 
436
+ # Mount the Gradio app at the root /
437
+ app = gr.mount_gradio_app(app, _demo, path="/")
438
+ logger.info("Gradio demo UI mounted at /")
439
 
440
+ @app.get("/demo")
441
  @app.get("/launch")
 
442
  async def demo_redirect():
443
  from fastapi.responses import RedirectResponse
444
+ return RedirectResponse(url="/")
445
 
446
  except Exception as _demo_exc:
447
  logger.error("Failed to mount Gradio demo UI: %s", _demo_exc, exc_info=True)