From 1a28d182344f2d081d1ded65e1d284d193e3fd76 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 10 Mar 2026 21:52:41 -0600 Subject: [PATCH] Format code --- main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index f13da6d..8704bcf 100644 --- a/main.py +++ b/main.py @@ -14,6 +14,8 @@ auto_stop_timer = None # Timer for automatic VNC stop @app.route('/cast', methods=['POST']) def cast_spell(): + global auto_stop_timer, LAST_CAST_ADDRESS + ip_address = request.form.get('ip_address') logging.info(f"Received POST request on /cast. Requested ip_address: {ip_address}") @@ -21,12 +23,11 @@ def cast_spell(): logging.warning(f"Invalid or missing ip_address parameter: {ip_address}") return f"Invalid or missing 'ip_address' parameter.", 400 - global auto_stop_timer, LAST_CAST_ADDRESS - logging.info(f"Casting to {ip_address}.") kill_vnc() # Kill any existing VNC session first cast_machine(ip_address) LAST_CAST_ADDRESS = ip_address + # Restart auto-stop timer if auto_stop_timer is not None and auto_stop_timer.is_alive(): auto_stop_timer.cancel() @@ -34,11 +35,13 @@ def cast_spell(): auto_stop_timer = threading.Timer(AUTO_STOP_TIMEOUT_SECONDS, _auto_stop_vnc) auto_stop_timer.start() logging.info(f"Scheduled auto-stop for VNC in {AUTO_STOP_TIMEOUT_SECONDS} seconds.") + return f"Successfully cast to {ip_address}.", 200 @app.route('/stop', methods=['POST']) def stop_cast(): global auto_stop_timer, LAST_CAST_ADDRESS + ip_address = request.form.get('ip_address') logging.info(f"Received POST request on /stop for ip_address: {ip_address}") @@ -57,6 +60,7 @@ def stop_cast(): kill_vnc() LAST_CAST_ADDRESS = None + return "Attempted to stop VNC viewers.", 200 def _auto_stop_vnc():