From a14921b79e88e1dfeffbaf2d76f38a51259e1e21 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sun, 18 Dec 2022 12:54:31 -0600 Subject: [PATCH] svc: Save config after navigation When a makes a *POST /screen/{name}/navigate* HTTP request, the URL list is updated and saved to the configuration file. This provides a mechanism for configuring the URL list, since it is now part of the display configuration file and not a separate file manged externally. --- svc/src/hudctrl/api.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/svc/src/hudctrl/api.py b/svc/src/hudctrl/api.py index 8d393c8..8f341b4 100644 --- a/svc/src/hudctrl/api.py +++ b/svc/src/hudctrl/api.py @@ -137,8 +137,14 @@ async def get_screenshot( '/screen/{name}/navigate', response_class=fastapi.responses.PlainTextResponse, ) -async def navigate(name: str, url: str = fastapi.Form(...)): +async def navigate( + bgtasks: fastapi.BackgroundTasks, + name: str, + url: str = fastapi.Form(...), +): await svc.navigate(name, url) + svc.urls[name] = url + bgtasks.add_task(svc.save_config) @app.on_event('shutdown')