| """ |
| Main application entry point for Scrapling Hugging Face Space. |
| Combines FastAPI REST API with Gradio web interface. |
| """ |
|
|
| import gradio as gr |
| from fastapi import FastAPI |
| from fastapi.responses import HTMLResponse |
| from api import app as fastapi_app |
| from scrapling.ui import create_ui |
|
|
| |
| def mount_gradio_app(fastapi_app, blocks, path="/"): |
| """Mount Gradio blocks onto FastAPI app.""" |
| from gradio.routes import mount_gradio_app as gr_mount |
| return gr_mount(fastapi_app, blocks, path=path) |
|
|
| |
| app = mount_gradio_app(fastapi_app, create_ui(), path="/") |
|
|
| |
| @app.get("/docs", response_class=HTMLResponse) |
| async def custom_docs(): |
| """Serve custom HTML API documentation.""" |
| with open("docs.html", "r") as f: |
| return f.read() |
|
|
| if __name__ == "__main__": |
| import uvicorn |
| uvicorn.run(app, host="0.0.0.0", port=7860) |
|
|