diff options
author | Frederick Yin <fkfd@fkfd.me> | 2021-10-31 14:23:29 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2021-10-31 14:23:29 +0800 |
commit | 6392802d696a228250cce7f9ddeaca8f6fb92b29 (patch) | |
tree | 8c36ca9b3c8048a889589ec5f19994df7957aa90 /jimbrella | |
parent | 5bf44bd6be9d0390c845bc20b7e416ad0085790f (diff) |
Config: read from TOML file
Diffstat (limited to 'jimbrella')
-rw-r--r-- | jimbrella/config.py | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/jimbrella/config.py b/jimbrella/config.py index 77e944e..85833d0 100644 --- a/jimbrella/config.py +++ b/jimbrella/config.py @@ -1,14 +1,22 @@ -# jForm -JFORM_TAKEAWAY_URL = ( - "https://wj.sjtu.edu.cn/api/v1/public/export/900e25bf6a039da04da7c5165a7cd41a/json" -) -# JFORM_GIVEBACK_URL= ( -# "https://wj.sjtu.edu.cn/api/v1/public/export/900e25bf6a039da04da7c5165a7cd41a/json" -# ) -JFORM_BOOKMARK_DIR = "/home/fkfd/p/jimbrella/" - -# database -DATABASE_PATH = "/home/fkfd/p/jimbrella/jimbrella.db.csv" - -# rules of service -DUE_HOURS = 72 +import os +import toml + +config_path = os.environ["JIMBRELLA_CONFIG"] or "/opt/jimbrella/config.toml" + +f = open(config_path) +config = toml.load(f) +f.close() + +FLASK_SECRET_KEY = config["flask"]["secret_key"] + +JFORM_TAKEAWAY_URL = config["jform"]["takeaway_url"] +JFORM_GIVEBACK_URL = config["jform"]["giveback_url"] +JFORM_BOOKMARK_DIR = config["jform"]["bookmark_dir"] + +DATABASE_PATH = config["db"]["db_path"] +USERS_PATH = config["db"]["users_path"] + +DUE_HOURS = config["rules"]["due_hours"] + +LOG_PATH = config["logging"]["log_path"] +ADMIN_LOG_PATH = config["logging"]["admin_log_path"] |