From 31309a8ee3a5dea75d36fe6c6783276f913eeb4c Mon Sep 17 00:00:00 2001 From: Daniel Markstedt Date: Sat, 29 Jan 2022 09:41:39 -0800 Subject: [PATCH] Make the default config load on rascsi-web startup without having to load it in a browser. (#620) --- python/web/src/web.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/web/src/web.py b/python/web/src/web.py index c36c2874..6c34d1bb 100644 --- a/python/web/src/web.py +++ b/python/web/src/web.py @@ -1021,17 +1021,14 @@ def change_language(): @APP.before_first_request -def load_default_config(): +def detect_locale(): """ - Webapp initialization steps that require the Flask app to have started: - - Get the detected locale to use for localizations - - Load the default configuration file, if found + Get the detected locale to use for UI string translations. + This requires the Flask app to have started first. """ session["language"] = get_locale() ractl.locale = session["language"] file_cmds.locale = session["language"] - if Path(f"{CFG_DIR}/{DEFAULT_CONFIG}").is_file(): - file_cmds.read_config(DEFAULT_CONFIG) if __name__ == "__main__": @@ -1075,6 +1072,9 @@ if __name__ == "__main__": ractl = RaCtlCmds(sock_cmd=sock_cmd, token=APP.config["TOKEN"]) file_cmds = FileCmds(sock_cmd=sock_cmd, ractl=ractl, token=APP.config["TOKEN"]) + if Path(f"{CFG_DIR}/{DEFAULT_CONFIG}").is_file(): + file_cmds.read_config(DEFAULT_CONFIG) + import bjoern print("Serving rascsi-web...") bjoern.run(APP, "0.0.0.0", arguments.port)