File size: 687 Bytes
a906083 f00f379 24717ec 2aed3fd af46212 24717ec a906083 3be496d c1ba890 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 |
from fastapi import FastAPI
from routes.category import router # routes.py must be in same folder
from routes.question import askMe
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.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"}
|