todoapp-7thmky/main.py
Automated Action e35edd0f6a Add database models and SQLAlchemy setup for todo app
- Created app directory structure with db, models, and schemas modules
- Added SQLAlchemy Base class in app/db/base.py to prevent circular imports
- Implemented database session setup with SQLite configuration
- Created Todo model with id, title, description, completed, created_at, updated_at fields
- Added Pydantic schemas for TodoCreate, TodoUpdate, and TodoResponse
- Added requirements.txt with FastAPI, SQLAlchemy, and other dependencies
2025-06-19 00:41:31 +00:00

42 lines
967 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
app = FastAPI(
title="Todo App API",
description="A simple todo application API",
version="1.0.0",
openapi_url="/openapi.json"
)
# Configure CORS to allow all origins
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
async def root():
"""Base URL endpoint returning project information"""
return {
"title": "Todo App API",
"documentation": "/docs",
"redoc": "/redoc",
"health": "/health",
"openapi": "/openapi.json"
}
@app.get("/health")
async def health_check():
"""Health check endpoint"""
return {"status": "healthy", "message": "Todo App API is running"}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)