Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tokeshu/requests-eventsource

Requests + EventSource = <3
https://github.com/tokeshu/requests-eventsource

Last synced: about 2 months ago
JSON representation

Requests + EventSource = <3

Awesome Lists containing this project

README

        

Requests EventSource
=====================

requests-eventsource is an EventSource_ implementation on top of
Requests_ and eventsource-parser_.

.. _EventSource: http://www.w3.org/TR/eventsource/
.. _Requests: http://docs.python-requests.org/
.. _eventsource-parser: https://github.com/tOkeshu/eventsource-parser

Example
-------

::

import requests
from requests_eventsource import eventsource

r = requests.get('http://example.com/ev', stream=True)
for event in eventsource(r):
if event.type == 'rpc':
do_something(event)
if event.type == 'json':
print(json.loads(event.data))

License
-------

Licensed under the Apache License, Version 2.0.