unwind/unwind/config.py
ducklet 9acd534706 make more aspects of API & UI hosting configurable
This is necessary to create proper dev & production builds of the app.
2021-08-05 19:18:51 +02:00

21 lines
641 B
Python

import os
from pathlib import Path
import toml
datadir = Path(os.getenv("UNWIND_DATA") or "./data")
cachedir = (
Path(cachedir)
if (cachedir := os.getenv("UNWIND_CACHEDIR", datadir / ".cache"))
else None
)
debug = os.getenv("DEBUG") == "1"
loglevel = os.getenv("UNWIND_LOGLEVEL") or ("DEBUG" if debug else "INFO")
storage_path = os.getenv("UNWIND_STORAGE", datadir / "db.sqlite")
config_path = os.getenv("UNWIND_CONFIG", datadir / "config.toml")
_config = toml.load(config_path)
api_base = _config["api"].get("base", "/api/")
api_cors = _config["api"].get("cors", "*")
api_credentials = _config["api"].get("credentials", {})