MCPcopy Create free account
hub / github.com/SiddhantSilwal/RaspberryPi-GPIO-Web-Controller / generate

Function generate

AppData/app.py:505–519  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

503def event_stream():
504 """Server-Sent Events endpoint for real-time updates"""
505 def generate():
506 try:
507 while True:
508 try:
509 # Wait for events with timeout
510 event = event_queue.get(timeout=30)
511 yield f"data: {json.dumps(event)}\n\n"
512 except queue.Empty:
513 # Send heartbeat to keep connection alive
514 yield f"data: {json.dumps({'type': 'heartbeat'})}\n\n"
515 except Exception as e:
516 yield f"data: {json.dumps({'type': 'error', 'message': str(e)})}\n\n"
517 break
518 except GeneratorExit:
519 pass
520
521 return Response(generate(), mimetype='text/plain', headers={
522 'Cache-Control': 'no-cache',

Callers 2

event_streamFunction · 0.85
graph_streamFunction · 0.85

Calls 4

cleanup_pinFunction · 0.85
log_eventFunction · 0.85
setupMethod · 0.80
PWMMethod · 0.80

Tested by

no test coverage detected