AzizMiladi Claude Opus 4.7 commited on
Commit
495dc91
Β·
1 Parent(s): 358ff4b

feat(api): redirect / to /docs so the HF Space App tab shows Swagger

Browse files

Previously GET / returned 404 (no route defined), which made the
HuggingFace Space App tab look broken even though the API was healthy.
A 307 redirect to FastAPI's auto-generated Swagger UI gives any
browser visitor a usable landing page and a way to explore + try
endpoints with their API key.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Files changed (1) hide show
  1. src/guichetoi/api/main.py +6 -1
src/guichetoi/api/main.py CHANGED
@@ -75,7 +75,7 @@ from pathlib import Path
75
 
76
  from fastapi import Depends, FastAPI, File, Header, HTTPException, Response, UploadFile, status
77
  from fastapi.middleware.cors import CORSMiddleware
78
- from fastapi.responses import JSONResponse
79
 
80
  from guichetoi import cms as cms_gen
81
  from guichetoi import recommendation as reco
@@ -257,6 +257,11 @@ def _require_engine(app: FastAPI):
257
  # ────────────────────────────────────────────────────────────────────────────
258
  # Routes
259
  # ────────────────────────────────────────────────────────────────────────────
 
 
 
 
 
260
  @app.get("/health", tags=["meta"])
261
  def health() -> dict:
262
  """Liveness + readiness. Spring Boot polls this before routing traffic."""
 
75
 
76
  from fastapi import Depends, FastAPI, File, Header, HTTPException, Response, UploadFile, status
77
  from fastapi.middleware.cors import CORSMiddleware
78
+ from fastapi.responses import JSONResponse, RedirectResponse
79
 
80
  from guichetoi import cms as cms_gen
81
  from guichetoi import recommendation as reco
 
257
  # ────────────────────────────────────────────────────────────────────────────
258
  # Routes
259
  # ────────────────────────────────────────────────────────────────────────────
260
+ @app.get("/", include_in_schema=False)
261
+ def root() -> RedirectResponse:
262
+ return RedirectResponse(url="/docs")
263
+
264
+
265
  @app.get("/health", tags=["meta"])
266
  def health() -> dict:
267
  """Liveness + readiness. Spring Boot polls this before routing traffic."""