mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-22 16:33:17 +00:00
Make the default config load on rascsi-web startup without having to load it in a browser. (#620)
This commit is contained in:
parent
089dc302e5
commit
31309a8ee3
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user