mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-21 00:40:01 +02:00
rewrites web server to hot-reload the web settings from the settings file
This commit is contained in:
parent
ef36c01407
commit
6543bc6b39
@ -106,7 +106,6 @@ class WebServer:
|
||||
def _initialise_configuration(self) -> None:
|
||||
logger.debug("Initialising web server configuration...")
|
||||
|
||||
self.web_settings = {}
|
||||
file_path = self._service_config_dir / "web_settings.json"
|
||||
|
||||
if self._generate_new_web_settings:
|
||||
@ -119,15 +118,6 @@ class WebServer:
|
||||
json.dumps(self._generated_web_settings_dict(), indent=4)
|
||||
)
|
||||
|
||||
# File exists, read and return its content
|
||||
if file_path.exists():
|
||||
logger.debug(
|
||||
"Reading configuration from file '%s' ...", file_path.absolute()
|
||||
)
|
||||
|
||||
with file_path.open("r", encoding="utf-8") as file:
|
||||
self.web_settings = json.load(file)
|
||||
|
||||
def _generated_web_settings_dict(self) -> dict[str, dict[str, Any]]:
|
||||
return {
|
||||
path: {"displayName": path.split(".")[-1], "index": i}
|
||||
@ -167,7 +157,19 @@ class WebServer:
|
||||
|
||||
@app.get("/web-settings")
|
||||
def web_settings() -> dict[str, Any]:
|
||||
return self.web_settings
|
||||
file_path = self._service_config_dir / "web_settings.json"
|
||||
web_settings = {}
|
||||
|
||||
# File exists, read its content
|
||||
if file_path.exists():
|
||||
logger.debug(
|
||||
"Reading configuration from file '%s' ...", file_path.absolute()
|
||||
)
|
||||
|
||||
with file_path.open("r", encoding="utf-8") as file:
|
||||
web_settings = json.load(file)
|
||||
|
||||
return web_settings
|
||||
|
||||
# exposing custom.css file provided by user
|
||||
if self.css is not None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user