
- Set up project structure with FastAPI application - Create Todo model and related Pydantic schemas - Implement CRUD operations for Todo items - Add health endpoint for application monitoring - Configure database connection with SQLite - Create database migrations with Alembic - Update documentation with setup and usage instructions generated with BackendIM... (backend.im)
28 lines
882 B
Python
28 lines
882 B
Python
from typing import List, Optional, Union
|
|
from pydantic import AnyHttpUrl, validator
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Simple Todo Application"
|
|
PROJECT_VERSION: str = "0.1.0"
|
|
PROJECT_DESCRIPTION: str = "A simple Todo application API built with FastAPI and SQLite"
|
|
|
|
# CORS Configuration
|
|
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []
|
|
|
|
@validator("BACKEND_CORS_ORIGINS", pre=True)
|
|
def assemble_cors_origins(cls, v: Union[str, List[str]]) -> Union[List[str], str]:
|
|
if isinstance(v, str) and not v.startswith("["):
|
|
return [i.strip() for i in v.split(",")]
|
|
elif isinstance(v, (list, str)):
|
|
return v
|
|
raise ValueError(v)
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
case_sensitive = True
|
|
|
|
|
|
settings = Settings() |