Format code

This commit is contained in:
2026-03-10 21:52:41 -06:00
parent 38f4d5c5e2
commit 1a28d18234

View File

@@ -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():