Automated Action aaac87335a Fix ModuleNotFoundError for pydantic_settings
- Added pydantic and pydantic-settings to requirements.txt
- Updated config.py to use proper Pydantic v2 imports and patterns
- Updated schemas to use Pydantic v2 configuration format
- Replaced orm_mode with from_attributes=True in schema models
- Applied code formatting with Ruff
2025-06-09 13:43:01 +00:00

32 lines
869 B
Python

from pathlib import Path
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
PROJECT_NAME: str = "File Upload Download API"
API_V1_STR: str = "/api/v1"
# Base directory for storage
STORAGE_DIR: Path = Path("/app/storage")
# File storage directory
FILE_STORAGE_DIR: Path = STORAGE_DIR / "files"
# Database
DB_DIR: Path = STORAGE_DIR / "db"
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
# Configure max file size (10MB by default)
MAX_FILE_SIZE: int = 10 * 1024 * 1024 # 10MB in bytes
model_config = SettingsConfigDict(case_sensitive=True, env_file=".env")
# Create settings instance
settings = Settings()
# Ensure storage directories exist
settings.DB_DIR.mkdir(parents=True, exist_ok=True)
settings.FILE_STORAGE_DIR.mkdir(parents=True, exist_ok=True)