Files
ai-video-fullstack/backend/settings.py
Xin Wang 35d24acf40 Refactor backend configuration management and update environment settings
- Replace the `config.py` module with a new `settings.py` to streamline environment variable management, focusing on database, CORS, and TURN settings.
- Update references throughout the backend codebase to use the new `settings` module instead of the deprecated `config`.
- Modify the `.env.example` file to reflect the new configuration approach, indicating that model provider credentials should be maintained separately.
- Enhance the `AssistantConfig` model to clarify the source of runtime connection information, ensuring it is injected from model resources rather than relying on defaults from the environment.
- Introduce new user scripts for audio and video management in the Tampermonkey environment, enhancing WebRTC capabilities.
2026-07-09 21:40:29 +08:00

40 lines
1.1 KiB
Python

"""Runtime settings for backend infrastructure.
Model provider credentials live in ``model_resources`` and are resolved per
assistant. Keep this module limited to process-level settings such as database,
CORS, server bind address, and WebRTC ICE/TURN configuration.
"""
import os
from dotenv import load_dotenv
load_dotenv()
def _split(value: str) -> list[str]:
return [item.strip() for item in value.split(",") if item.strip()]
# ---- Database ----
DATABASE_URL = os.getenv(
"DATABASE_URL",
"postgresql+asyncpg://postgres:postgres@localhost:5432/postgres",
)
# ---- Service ----
HOST = os.getenv("HOST", "0.0.0.0")
PORT = int(os.getenv("PORT", "8000"))
CORS_ORIGINS = _split(
os.getenv("CORS_ORIGINS", "http://localhost:3000,http://127.0.0.1:3000")
)
# ---- WebRTC TURN ----
# TURN_URLS example:
# turn:182.92.86.220:3478?transport=udp,turn:182.92.86.220:3478?transport=tcp
TURN_URLS = _split(os.getenv("TURN_URLS", ""))
TURN_SECRET = os.getenv("TURN_SECRET", "")
TURN_USERNAME = os.getenv("TURN_USERNAME", "")
TURN_PASSWORD = os.getenv("TURN_PASSWORD", "")
TURN_CREDENTIAL_TTL = int(os.getenv("TURN_CREDENTIAL_TTL", "86400"))