Revert to documented @app .get('/', response_class=HTMLResponse) pattern
Browse files74 unmodified lines7576777879808182838485868788899074 unmodified linesyield {"role": "assistant", "content": out}# Bypass Gradio's auto-registered / route by mounting directly on the FastAPI appdef _homepage():html_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "index.html")with open(html_path, "r", encoding="utf-8") as f:html = f.read()return HTMLResponse(content=html, media_type="text/html")# Register on the underlying FastAPI app — must be done before launch()app.app.add_api_route("/", _homepage, methods=["GET"], response_class=HTMLResponse)app.launch(show_error=True)74 unmodified lines757677787980818283848574 unmodified linesyield {"role": "assistant", "content": out}@app.get("/", response_class=HTMLResponse)async def homepage():html_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "index.html")with open(html_path, "r", encoding="utf-8") as f:return f.read()app.launch(show_error=True)
app.py+3-8