From 48e587f580b684136675d4babd4e666a804b80a5 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Fri, 24 Apr 2026 08:09:47 +1000 Subject: [PATCH] BE: DEEP_SLEEP #1555 co-author @legionGer Signed-off-by: jokob-sk --- server/api.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/api.py b/server/api.py index f1c71b64..b65d23e1 100755 --- a/server/api.py +++ b/server/api.py @@ -262,8 +262,14 @@ def update_GUI_port(): Grabs the PORT for the webinterface and converts it to HEX to use for activity checks """ global hex_gui_port - gui_port_string = port = os.environ.get('PORT', defaultWebPort) - hex_gui_port = ':'+format(int(gui_port_string), '04X') + + gui_port_string = os.environ.get('PORT', str(defaultWebPort)) + try: + port = int(gui_port_string) + except (TypeError, ValueError): + mylog("none", [f"[API] Invalid PORT value '{gui_port_string}', falling back to {defaultWebPort}"]) + port = defaultWebPort + hex_gui_port = ':' + format(port, '04X') def check_activity():