Make the default config load on rascsi-web startup without having to load it in a browser. (#620)

This commit is contained in:
Daniel Markstedt 2022-01-29 09:41:39 -08:00 committed by GitHub
parent 089dc302e5
commit 31309a8ee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -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)