Spaces:
Sleeping
Sleeping
Download main.py from Qurrah/replyflow-rag: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/spaces/Qurrah/replyflow-rag/resolve/main/main.py
- Command line
-
hf download hf://spaces/Qurrah/replyflow-rag/main.py
-
curl -L -o main.py https://huggingface.co/spaces/Qurrah/replyflow-rag/resolve/main/main.py
1.25 kB
| import logging | |
| from fastapi import FastAPI, Request | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from fastapi.responses import JSONResponse | |
| from api.errors import add_exception_handlers | |
| from api.routes import admin, documents, onboarding, query | |
| from core.config import APP_DESCRIPTION, APP_TITLE, APP_VERSION | |
| from core.logging import configure_logging | |
| configure_logging() | |
| logger = logging.getLogger(__name__) | |
| app = FastAPI( | |
| title=APP_TITLE, | |
| description=APP_DESCRIPTION, | |
| version=APP_VERSION, | |
| ) | |
| # Centralized Error Handling | |
| add_exception_handlers(app) | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| async def log_requests(request: Request, call_next): | |
| logger.info(f"START | {request.method} {request.url.path}") | |
| response = await call_next(request) | |
| logger.info(f"END | {request.method} {request.url.path} | status={response.status_code}") | |
| return response | |
| app.include_router(query.router) | |
| app.include_router(onboarding.router) | |
| app.include_router(documents.router) | |
| app.include_router(admin.router) | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run("main:app", host="0.0.0.0", port=7860, reload=False) | |