
- Add SQLAlchemy models for Todo with timestamps - Create Pydantic schemas for request/response validation - Implement CRUD operations for Todo management - Add REST API endpoints for todo operations (GET, POST, PUT, DELETE) - Configure SQLite database with proper connection settings - Set up Alembic migrations for database schema management - Add comprehensive API documentation and health check endpoint - Enable CORS for all origins - Include proper error handling and HTTP status codes - Update README with complete setup and usage instructions
38 lines
686 B
Python
38 lines
686 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class TodoBase(BaseModel):
|
|
"""Base schema for Todo."""
|
|
|
|
title: str
|
|
description: Optional[str] = None
|
|
completed: bool = False
|
|
|
|
|
|
class TodoCreate(TodoBase):
|
|
"""Schema for creating a Todo."""
|
|
|
|
pass
|
|
|
|
|
|
class TodoUpdate(BaseModel):
|
|
"""Schema for updating a Todo."""
|
|
|
|
title: Optional[str] = None
|
|
description: Optional[str] = None
|
|
completed: Optional[bool] = None
|
|
|
|
|
|
class TodoResponse(TodoBase):
|
|
"""Schema for Todo response."""
|
|
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|