todoapp-xht8o2/app/core/config.py
Automated Action fd0d96616b Initial setup of FastAPI Todo Application
- Set up project structure
- Create FastAPI app with SQLite database
- Implement Todo API with CRUD operations
- Set up Alembic for database migrations
- Add health endpoint
- Create README with documentation
2025-05-27 10:47:50 +00:00

30 lines
979 B
Python

from pathlib import Path
from typing import List, Union
from pydantic import AnyHttpUrl, BaseSettings, validator
class Settings(BaseSettings):
API_V1_STR: str = "/api/v1"
# BACKEND_CORS_ORIGINS is a JSON-formatted list of origins
# e.g: '["http://localhost", "http://localhost:4200", "http://localhost:3000", \
# "http://localhost:8080"]'
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)
PROJECT_NAME: str = "Todo App API"
# Database
DB_DIR = Path("/app") / "storage" / "db"
DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
settings = Settings()