togethere.cloud/api/config.py

58 lines
1.6 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Konfiguracja serwisu plików Togethere.
Wartości ładowane z pliku .env (lub zmiennych środowiskowych).
"""
from __future__ import annotations
import os
from pathlib import Path
from typing import List
try:
from pydantic_settings import BaseSettings
from pydantic import field_validator
except ImportError: # starsze wersje pydantic
from pydantic import BaseSettings, validator as field_validator # type: ignore
class Settings(BaseSettings):
# Klucz API współdzielony z PHP zmień w .env przed deplojem
api_key: str = "CHANGE_ME_BEFORE_DEPLOY"
# Katalog bazowy dla plików (poza public_html)
files_base_dir: Path = Path("/var/www/togethere.cloud/files")
# Maks. rozmiar pliku w MB
max_file_size_mb: int = 20
# Port, na którym nasłuchuje serwis (tylko localhost)
host: str = "127.0.0.1"
port: int = 8001
# Dozwolone typy MIME
allowed_mime_types: List[str] = [
"image/jpeg",
"image/png",
"image/gif",
"image/webp",
"application/pdf",
"text/plain",
"text/markdown",
"text/x-markdown",
"application/zip",
"video/mp4",
"audio/mpeg",
"audio/wav",
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.ms-excel",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
]
class Config:
env_file = os.path.join(os.path.dirname(__file__), ".env")
env_file_encoding = "utf-8"
settings = Settings()