Mercurial > code > home > repos > homeauto
diff service/reasoning/twisted_sse_demo/api_example.py @ 1099:cb94ea3495b2
Copy from from https://github.com/juggernaut/twisted-sse-demo
Ignore-this: a252d3c6e023cb83fd10bfbae78e05d9
darcs-hash:bd76fd3b996c7225f03930b3796dc4ddc7783d9a
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Fri, 19 Aug 2016 10:53:03 -0700 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/service/reasoning/twisted_sse_demo/api_example.py Fri Aug 19 10:53:03 2016 -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)