Spaces:
Sleeping
Sleeping
| from contextlib import asynccontextmanager | |
| from pathlib import Path | |
| from dotenv import load_dotenv | |
| load_dotenv(Path(__file__).parent / ".env") | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from api.routes import router | |
| from db.history import init_db | |
| from scraper.scheduler import start_scheduler, stop_scheduler | |
| async def lifespan(app: FastAPI): | |
| init_db() | |
| start_scheduler() | |
| yield | |
| stop_scheduler() | |
| app = FastAPI( | |
| title="AgentRax Help Agent API", | |
| description=( | |
| "Official AI support assistant for AgentRax β answers questions about features, " | |
| "pricing, how-to guides, and platform usage using live website content and indexed documents." | |
| ), | |
| version="2.0.0", | |
| lifespan=lifespan, | |
| ) | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["http://localhost:3000", "https://*.hf.space"], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| app.include_router(router) | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) | |