
- Set up FastAPI application with SQLite database - Implement User and Item models with relationships - Add CRUD operations for users and items - Configure Alembic for database migrations - Include API documentation at /docs and /redoc - Add health check endpoint at /health - Enable CORS for all origins - Structure code with proper separation of concerns
23 lines
477 B
Python
23 lines
477 B
Python
from typing import Optional
|
|
from pydantic import BaseModel
|
|
from datetime import datetime
|
|
|
|
class ItemBase(BaseModel):
|
|
title: str
|
|
description: Optional[str] = None
|
|
|
|
class ItemCreate(ItemBase):
|
|
pass
|
|
|
|
class ItemUpdate(BaseModel):
|
|
title: Optional[str] = None
|
|
description: Optional[str] = None
|
|
|
|
class Item(ItemBase):
|
|
id: int
|
|
owner_id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True |