
- Created project structure with FastAPI setup - Added SQLite database connection with SQLAlchemy ORM - Implemented Todo model and schemas - Added CRUD operations for Todo items - Created API endpoints for Todo management - Added health check endpoint - Configured Alembic for database migrations - Updated project documentation in README.md
37 lines
928 B
Python
37 lines
928 B
Python
from pathlib import Path
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.api.routers import router as api_router
|
|
from app.core.config import settings
|
|
|
|
app = FastAPI(
|
|
title=settings.PROJECT_NAME,
|
|
description=settings.PROJECT_DESCRIPTION,
|
|
version=settings.PROJECT_VERSION,
|
|
openapi_url=f"{settings.API_V1_STR}/openapi.json",
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
)
|
|
|
|
# Set up CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.CORS_ORIGINS,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include API router
|
|
app.include_router(api_router, prefix=settings.API_V1_STR)
|
|
|
|
# Ensure storage directory exists
|
|
storage_dir = Path("/app/storage")
|
|
storage_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) |