FastAPI / app.py
raghavNCI
wa gateway
ecbc095
raw
history blame
826 Bytes
from fastapi import FastAPI
from routes.category import router # routes.py must be in same folder
from routes.question import askMe
from routes.headlines import headlines
from routes.wa_gateway import wa_router
from dotenv import load_dotenv
from cache_init import fetch_and_cache_articles
from fastapi.middleware.cors import CORSMiddleware
load_dotenv()
app = FastAPI()
app.include_router(router)
app.include_router(askMe)
app.include_router(headlines)
app.include_router(wa_router)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Or restrict to your frontend domain
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.on_event("startup")
async def startup_event():
fetch_and_cache_articles()
@app.get("/health")
def health_check():
return {"status": "ok"}