SSE
===
Simple asyncio/aiohttp wrapper for Server-Sent Events.
Usage
-----
Sending events:
```python
import asyncio
import sse
class Handler(sse.Handler):
@asyncio.coroutine
def handle_request(self):
yield from asyncio.sleep(2)
self.send('foo')
yield from asyncio.sleep(2)
self.send('bar', event='wakeup')
start_server = sse.serve(Handler, 'localhost', 8888)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
```
Validating incoming requests:
```python
class Handler(sse.Handler):
def validate_sse(self):
super().validate_sse()
# use self.request / self.payload
if not self.request.path.startswith('/live'):
raise sse.SseException()
```
Sending JSON data:
```python
class Handler(sse.Handler):
@asyncio.coroutine
def handle_request(self):
self.send({'foo': 'bar'})
```
Sending IDs / event names / retry information:
```python
class Handler(sse.Handler):
@asyncio.coroutine
def handle_request(self):
self.send('some data', id=12345, event='something', retry=10000)
```
===
Simple asyncio/aiohttp wrapper for Server-Sent Events.
Usage
-----
Sending events:
```python
import asyncio
import sse
class Handler(sse.Handler):
@asyncio.coroutine
def handle_request(self):
yield from asyncio.sleep(2)
self.send('foo')
yield from asyncio.sleep(2)
self.send('bar', event='wakeup')
start_server = sse.serve(Handler, 'localhost', 8888)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
```
Validating incoming requests:
```python
class Handler(sse.Handler):
def validate_sse(self):
super().validate_sse()
# use self.request / self.payload
if not self.request.path.startswith('/live'):
raise sse.SseException()
```
Sending JSON data:
```python
class Handler(sse.Handler):
@asyncio.coroutine
def handle_request(self):
self.send({'foo': 'bar'})
```
Sending IDs / event names / retry information:
```python
class Handler(sse.Handler):
@asyncio.coroutine
def handle_request(self):
self.send('some data', id=12345, event='something', retry=10000)
```
Release files for asyncio-sse 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| asyncio-sse-0.1.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asyncio_sse-0.1-py33-none-any.whl | Python 3.3 | none | any | Details |
Total release size: 9.0 kB
Release files / asyncio-sse-0.1.tar.gz
| Download URL | asyncio-sse-0.1.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
abba9240f92fbf69617e4865cd7dafda9bd38265d2f9447970a34f6945076acf
|
|
BLAKE2b-256 checksum How to use checksums |
74a7af14384cd397dab9619441cbaf974c19838b1df88f278f531d6979d5e749
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / asyncio_sse-0.1-py33-none-any.whl
| Download URL | asyncio_sse-0.1-py33-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3.3 |
|
SHA-256 checksum How to use checksums |
81cf9757e023c91998f8243fa5db1632eb8d0174a6c9da466c085345a603e1c8
|
|
BLAKE2b-256 checksum How to use checksums |
3b314a319452374caa3d16c44ee16ae33df0cf1a8de4683a8d73e135d7317f9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |