askrobots / dbbasic-web
Public
A Unix-style Python web framework: filesystem routing, flat files, messages and cron, with CGI's simplicity at modern speed.
Dan Quellhorst
Replace multipart parser with stdlib-only implementation
eb957a2
9 months, 2 weeks ago
History
settings.py · 815 bytes · 27 lines
| 1 | """Application settings and configuration""" |
| 2 | import os |
| 3 | from pathlib import Path |
| 4 | |
| 5 | # Allow override from environment or use current working directory if api/ exists |
| 6 | _cwd = Path.cwd() |
| 7 | if (_cwd / "api").exists() or (_cwd / "templates").exists(): |
| 8 | # Running from a project directory |
| 9 | BASE_DIR = _cwd |
| 10 | PROJECT_ROOT = _cwd.parent |
| 11 | else: |
| 12 | # Running from installed package (fallback) |
| 13 | BASE_DIR = Path(__file__).resolve().parent |
| 14 | PROJECT_ROOT = BASE_DIR.parent |
| 15 | |
| 16 | DEBUG = os.getenv("DEBUG", "1") == "1" |
| 17 | |
| 18 | # Static / templates |
| 19 | TEMPLATES_DIR = BASE_DIR / "templates" |
| 20 | PUBLIC_DIR = BASE_DIR / "public" |
| 21 | |
| 22 | # File storage root (flat files, TSV databases, job queues, event streams) |
| 23 | DATA_DIR = PROJECT_ROOT / "_data" |
| 24 | DATA_DIR.mkdir(exist_ok=True) |
| 25 | |
| 26 | # Security |
| 27 | SECRET_KEY = os.getenv("SECRET_KEY", "dev-secret-change-me") |