
- Create FastAPI application with CORS support - Add SQLAlchemy models for Todo with timestamps - Set up SQLite database with proper configuration - Create CRUD operations for todo management - Add REST API endpoints for all todo operations - Configure Alembic for database migrations - Add Pydantic schemas for request/response validation - Include health check and root info endpoints - Set up proper project structure following best practices - Add comprehensive README with usage instructions
24 lines
507 B
Python
24 lines
507 B
Python
from pydantic import BaseModel
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
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: datetime
|
|
|
|
class Config:
|
|
from_attributes = True |