Automated Action d20c3af0bc Build a simple Todo app with FastAPI
- Setup project structure with FastAPI, SQLAlchemy, and SQLite
- Create Todo model and database migrations
- Implement CRUD API endpoints
- Add error handling and validation
- Update README with documentation and examples

generated with BackendIM... (backend.im)
2025-05-15 22:01:40 +00:00

28 lines
687 B
Python

from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field
class TodoBase(BaseModel):
title: str = Field(..., min_length=1, max_length=100)
description: Optional[str] = Field(None, max_length=500)
completed: bool = False
class TodoCreate(TodoBase):
pass
class TodoUpdate(BaseModel):
title: Optional[str] = Field(None, min_length=1, max_length=100)
description: Optional[str] = Field(None, max_length=500)
completed: Optional[bool] = None
class TodoInDB(TodoBase):
id: int
created_at: datetime
updated_at: Optional[datetime] = None
class Config:
orm_mode = True
class Todo(TodoInDB):
pass