unwind/unwind/config.py

21 lines
677 B
Python

import os
import tomllib
from pathlib import Path
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")
with open(config_path, "rb") as fd:
_config = tomllib.load(fd)
api_base = _config["api"].get("base", "/api/")
api_cors = _config["api"].get("cors", "*")
api_credentials = _config["api"].get("credentials", {})