Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
| from fastapi.responses import RedirectResponse | |
| import uvicorn | |
| from fastapi import FastAPI | |
| from server import router as mobile_router | |
| from app import gradio_app # your Blocks object | |
| import gradio as gr | |
| import logging | |
| from fastapi.middleware import Middleware | |
| from fastapi import Request | |
| logging.basicConfig(level=logging.INFO) | |
| app = FastAPI(title="Sanatan AI Unified Server") | |
| # Mount mobile endpoints | |
| app.include_router(mobile_router, prefix="/api") | |
| # Convert Gradio Blocks to ASGI app | |
| app = gr.mount_gradio_app(app, gradio_app,"/web") | |
| # Redirect root URL to /web/ | |
| async def redirect_to_web(): | |
| return RedirectResponse(url="/web/") | |
| async def log_requests(request: Request, call_next): | |
| logging.info(f"Request: {request.method} {request.url}") | |
| response = await call_next(request) | |
| logging.info(f"Response status: {response.status_code}") | |
| return response | |
| if __name__ == "__main__": | |
| uvicorn.run("main:app", host="0.0.0.0", port=7860) | |