Initial commit with authentication and routes for registering/login already set up

This commit is contained in:
2024-10-14 05:38:48 +00:00
commit f64068c8ff
23 changed files with 1253 additions and 0 deletions

29
app/main.py Normal file
View File

@ -0,0 +1,29 @@
from fastapi import FastAPI
from sqlalchemy.ext.asyncio import AsyncEngine
from contextlib import asynccontextmanager
from app.routers import auth # Assuming you have a router for auth logic
from app.database import engine
from app.models import Base
# Define a lifespan context manager to handle startup and shutdown events
@asynccontextmanager
async def lifespan(app: FastAPI):
# Run code before the app starts
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
# Yield control to run the app
yield
# Run code before the app shuts down (if needed)
await engine.dispose()
# Initialize the FastAPI app with the lifespan event handler
app = FastAPI(lifespan=lifespan)
# Register your API routes
app.include_router(auth.router)
@app.get("/")
async def root():
return {"message": "Hello World"}