
- Add project structure with FastAPI, SQLAlchemy, and Alembic - Implement Todo model with CRUD operations - Add REST API endpoints for todo management - Configure SQLite database with migrations - Include health check and API documentation endpoints - Add CORS middleware for all origins - Format code with Ruff
29 lines
529 B
Python
29 lines
529 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel
|
|
|
|
|
|
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 Todo(TodoBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|