feat(api): Add GUI state manipulation hooks with thread-safe queueing
This commit is contained in:
13
api_hooks.py
13
api_hooks.py
@@ -49,6 +49,19 @@ class HookHandler(BaseHTTPRequestHandler):
|
||||
self.send_header('Content-Type', 'application/json')
|
||||
self.end_headers()
|
||||
self.wfile.write(json.dumps({'status': 'updated'}).encode('utf-8'))
|
||||
elif self.path == '/api/gui':
|
||||
if not hasattr(app, '_pending_gui_tasks'):
|
||||
app._pending_gui_tasks = []
|
||||
if not hasattr(app, '_pending_gui_tasks_lock'):
|
||||
app._pending_gui_tasks_lock = threading.Lock()
|
||||
|
||||
with app._pending_gui_tasks_lock:
|
||||
app._pending_gui_tasks.append(data)
|
||||
|
||||
self.send_response(200)
|
||||
self.send_header('Content-Type', 'application/json')
|
||||
self.end_headers()
|
||||
self.wfile.write(json.dumps({'status': 'queued'}).encode('utf-8'))
|
||||
else:
|
||||
self.send_response(404)
|
||||
self.end_headers()
|
||||
|
||||
Reference in New Issue
Block a user