From a9ff795948238b0768d1f258a6a4887c64d0d692 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 24 Sep 2024 09:54:03 -0600 Subject: [PATCH] More api fixes (#13936) * Set correect return type for raw config * Simplify parsing * Formatting --- frigate/api/app.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frigate/api/app.py b/frigate/api/app.py index 8ffcc789b..7bf65b9b0 100644 --- a/frigate/api/app.py +++ b/frigate/api/app.py @@ -160,7 +160,9 @@ def config_raw(): raw_config = f.read() f.close() - return raw_config, 200 + return JSONResponse( + content=raw_config, media_type="text/plain", status_code=200 + ) @router.post("/config/save") @@ -259,13 +261,13 @@ def config_set(request: Request, body: AppConfigSetBody): f.close() try: - update_yaml_from_url(config_file, request.url) + update_yaml_from_url(config_file, str(request.url)) with open(config_file, "r") as f: new_raw_config = f.read() f.close() # Validate the config schema try: - config_obj = FrigateConfig.parse_yaml(new_raw_config) + config = FrigateConfig.parse(new_raw_config) except Exception: with open(config_file, "w") as f: f.write(old_raw_config) @@ -288,10 +290,7 @@ def config_set(request: Request, body: AppConfigSetBody): ) if body.requires_restart == 0: - request.app.frigate_config = FrigateConfig.parse_object( - config_obj, request.app.frigate_config.plus_api - ) - + request.app.frigate_config = config return JSONResponse( content=( {