forked from ahmedfgad/GeneticAlgorithmPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
61 lines (47 loc) · 2.06 KB
/
config.py
File metadata and controls
61 lines (47 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
Application configuration driven by the ENV environment variable.
- development: local Fernet key file (legacy behavior, e.g. C: drive on Windows)
- production: ENCRYPTION_KEY from environment (Railway)
"""
from __future__ import annotations
import os
from pathlib import Path
# ---------------------------------------------------------------------------
# Environment
# ---------------------------------------------------------------------------
ENV: str = os.getenv("ENV", "development").strip().lower()
IS_PRODUCTION: bool = ENV == "production"
IS_DEVELOPMENT: bool = ENV == "development"
if ENV not in ("production", "development"):
raise ValueError(f"ENV must be 'production' or 'development', got: {ENV!r}")
# ---------------------------------------------------------------------------
# Database
# ---------------------------------------------------------------------------
DATABASE_PATH: str = os.getenv(
"DATABASE_PATH",
str(Path(__file__).resolve().parent / "data" / "app.db"),
)
# ---------------------------------------------------------------------------
# Encryption (development = legacy local file; production = env var)
# ---------------------------------------------------------------------------
# Default path mirrors the typical Windows C: layout; on Linux use home dir.
_DEFAULT_DEV_KEY_PATH = (
"C:/.encryption_key"
if os.name == "nt"
else str(Path.home() / ".encryption_key")
)
DEV_ENCRYPTION_KEY_PATH: str = os.getenv(
"DEV_ENCRYPTION_KEY_PATH",
_DEFAULT_DEV_KEY_PATH,
)
# Production master key (Railway / cloud)
ENCRYPTION_KEY: str | None = os.getenv("ENCRYPTION_KEY")
# ---------------------------------------------------------------------------
# Streamlit Authenticator (cookie signing)
# ---------------------------------------------------------------------------
AUTH_COOKIE_NAME: str = os.getenv("AUTH_COOKIE_NAME", "app_auth_cookie")
AUTH_COOKIE_KEY: str = os.getenv(
"AUTH_COOKIE_KEY",
"change-this-cookie-signing-key-in-production",
)
AUTH_COOKIE_EXPIRY_DAYS: float = float(os.getenv("AUTH_COOKIE_EXPIRY_DAYS", "30"))