File size: 615 Bytes
7c68554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# File: main.py
from fastapi import FastAPI
from contextlib import asynccontextmanager
from routes import router
from db_schema import init_db

@asynccontextmanager
async def lifespan(app: FastAPI):
    print("🚀 Server is starting up...")
    # Ensure SQLite tables exist before handling requests
    init_db()
    yield
    print("🧹 Server is shutting down... Cleaned up!")

app = FastAPI(
    title="Swiggy Email API",
    description="Extract Swiggy orders from Gmail",
    version="1.0.0",
    lifespan=lifespan
)

app.include_router(router)

# Run with: uvicorn main:app --reload