File size: 826 Bytes
a906083 f00f379 601d9f9 ecbc095 24717ec 2aed3fd af46212 24717ec a906083 3be496d c1ba890 601d9f9 ecbc095 a906083 af46212 2aed3fd 3be496d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
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"}
|