The two routes offer reloading the whole movie database from IMDb, and reloading all users' IMDb ratings. These functions (or very similar) were already available using the CLI, but now they can be triggered remotely by an admin.
17 lines
527 B
Python
17 lines
527 B
Python
import os
|
|
from pathlib import Path
|
|
|
|
import toml
|
|
|
|
cachedir = (
|
|
Path(cachedir) if (cachedir := os.getenv("UNWIND_CACHEDIR", "./.cache")) else None
|
|
)
|
|
datadir = Path(os.getenv("UNWIND_DATA") or "./data")
|
|
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_credentials = _config["api"]["credentials"]
|