diff lib/twisted_sse/api_example.py @ 1313:630e0d1846b8

mv twisted_sse Ignore-this: a59fadbe80bc4a393b1dab8228e022c1 darcs-hash:dc218d166be8566000cc59eabaa71b2f9667fe9b
author drewp <drewp@bigasterisk.com>
date Mon, 22 Apr 2019 21:58:09 -0700
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/twisted_sse/api_example.py	Mon Apr 22 21:58:09 2019 -0700
@@ -0,0 +1,13 @@
+import time
+
+from eventsource import EventSource
+
+EVENTSOURCE_URL = 'http://localhost:12000/subscribe'
+
+def onmessage(data):
+    print('Got payload with data %s' % data)
+
+if __name__ == '__main__':
+    eventSource = EventSource(EVENTSOURCE_URL)
+    eventSource.onmessage(onmessage, callInThread=True)
+    time.sleep(20)