
- Created FastAPI application with CRUD operations for todos - Implemented SQLite database with SQLAlchemy ORM - Added Alembic for database migrations - Set up CORS middleware for all origins - Added health check endpoint at /health - Created comprehensive API documentation - Formatted code with Ruff linter - Updated README with project information Features: - Create, read, update, delete todos - Pagination support for listing todos - Auto-generated OpenAPI documentation at /docs - Health monitoring endpoint
29 lines
520 B
Python
29 lines
520 B
Python
from pydantic import BaseModel
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
|
|
class TodoBase(BaseModel):
|
|
title: str
|
|
description: Optional[str] = None
|
|
completed: bool = False
|
|
|
|
|
|
class TodoCreate(TodoBase):
|
|
pass
|
|
|
|
|
|
class TodoUpdate(BaseModel):
|
|
title: Optional[str] = None
|
|
description: Optional[str] = None
|
|
completed: Optional[bool] = None
|
|
|
|
|
|
class TodoResponse(TodoBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|