bf52bc3079
build-and-push / docker (push) Has been cancelled
Features: feed CRUD, per-feed ntfy target (incl. private servers), Telegram/webhook channels, keyword filters, image attachments, per-feed intervals, OPML import/export, notification history & stats, users with roles, admin alerts, RU/EN i18n, light/dark theme, notification preview, history search, activity chart. Dockerized. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
"""Application configuration loaded from environment variables."""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import secrets
|
|
from pathlib import Path
|
|
|
|
# Where persistent data (SQLite DB) lives. Mounted as a volume in Docker.
|
|
DATA_DIR = Path(os.getenv("DATA_DIR", "./data")).resolve()
|
|
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
DATABASE_URL = os.getenv("DATABASE_URL", f"sqlite:///{DATA_DIR / 'app.db'}")
|
|
|
|
# Secret used to sign session cookies. Generate a stable one if not provided,
|
|
# persisting it to disk so sessions survive restarts.
|
|
_SECRET_FILE = DATA_DIR / "secret.key"
|
|
|
|
|
|
def _load_secret() -> str:
|
|
env = os.getenv("SECRET_KEY")
|
|
if env:
|
|
return env
|
|
if _SECRET_FILE.exists():
|
|
return _SECRET_FILE.read_text().strip()
|
|
value = secrets.token_hex(32)
|
|
_SECRET_FILE.write_text(value)
|
|
return value
|
|
|
|
|
|
SECRET_KEY = _load_secret()
|
|
|
|
# Defaults used the first time the app starts (before any settings are saved).
|
|
DEFAULT_NTFY_SERVER = os.getenv("DEFAULT_NTFY_SERVER", "https://ntfy.sh")
|
|
DEFAULT_CHECK_INTERVAL = int(os.getenv("DEFAULT_CHECK_INTERVAL", "5")) # minutes
|
|
|
|
# Bootstrap admin credentials (only applied when the settings row is created).
|
|
ADMIN_USERNAME = os.getenv("ADMIN_USERNAME", "admin")
|
|
ADMIN_PASSWORD = os.getenv("ADMIN_PASSWORD", "admin")
|