Files
healthy-fit/backend/app/main.py
Carlos Escalante 48ffe3418a
All checks were successful
Deploy to VPS / deploy (push) Successful in 26s
Test CI/CD pipeline: add API version, update Login page
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 19:29:10 -06:00

39 lines
964 B
Python

from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.v1.api import api_router
from app.config import settings
from app.core.ai_config import configure_dspy
from app.db import init_db
from app.models import push_subscription # noqa: F401 — ensures table is created
from app.scheduler import start_scheduler, stop_scheduler
@asynccontextmanager
async def lifespan(app: FastAPI):
init_db()
configure_dspy()
start_scheduler()
yield
stop_scheduler()
app = FastAPI(title="Healthy Fit API", lifespan=lifespan)
app.add_middleware(
CORSMiddleware,
allow_origins=[o.strip() for o in settings.CORS_ORIGINS.split(",")],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(api_router, prefix="/api/v1")
@app.get("/")
def read_root():
return {"message": "Welcome to Healthy Fit API", "version": "1.0.0"}