Automated Action 163b82dab7 Fix deployment error with pydantic_settings
- Add pydantic-settings to requirements.txt
- Update config.py to handle missing pydantic_settings module
- Use fallback to regular pydantic BaseSettings if pydantic_settings is not available
2025-05-17 13:38:59 +00:00

29 lines
742 B
Python

from pathlib import Path
# Try to import from pydantic_settings, fall back to pydantic if not available
try:
from pydantic_settings import BaseSettings
except ImportError:
from pydantic import BaseSettings
class Settings(BaseSettings):
PROJECT_NAME: str = "SimpleTodoApp"
PROJECT_DESCRIPTION: str = (
"A simple Todo application API built with FastAPI and SQLite"
)
PROJECT_VERSION: str = "0.1.0"
# Database configuration
DB_DIR: Path = Path("/app") / "storage" / "db"
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
class Config:
env_file = ".env"
settings = Settings()
# Create DB directory if it doesn't exist
settings.DB_DIR.mkdir(parents=True, exist_ok=True)