Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dlech/debian-python-aiohttp-sse
Debian packaging for aiohtto-sse
https://github.com/dlech/debian-python-aiohttp-sse
Last synced: 15 days ago
JSON representation
Debian packaging for aiohtto-sse
- Host: GitHub
- URL: https://github.com/dlech/debian-python-aiohttp-sse
- Owner: dlech
- License: other
- Created: 2021-12-04T22:07:45.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T06:04:30.000Z (almost 2 years ago)
- Last Synced: 2024-10-31T20:03:29.222Z (2 months ago)
- Language: Python
- Size: 35.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
aiohttp-sse
===========
.. image:: https://travis-ci.org/aio-libs/aiohttp-sse.svg?branch=master
:target: https://travis-ci.org/aio-libs/aiohttp-sse.. image:: https://codecov.io/gh/aio-libs/aiohttp-sse/branch/master/graph/badge.svg
:target: https://codecov.io/gh/aio-libs/aiohttp-sse.. image:: https://pyup.io/repos/github/aio-libs/aiohttp-sse/shield.svg
:target: https://pyup.io/repos/github/aio-libs/aiohttp-sse/
:alt: Updates.. image:: https://badges.gitter.im/Join%20Chat.svg
:target: https://gitter.im/aio-libs/Lobby
:alt: Chat on GitterThe *EventSource** interface is used to receive server-sent events. It connects
to a server over HTTP and receives events in text/event-stream format without
closing the connection. *aiohttp-sse* provides support for server-sent
events for aiohttp_.Installation
------------
Installation process as simple as::$ pip install aiohttp-sse
Mailing List
------------*aio-libs* google group: https://groups.google.com/forum/#!forum/aio-libs
Example
-------
.. code:: pythonimport asyncio
from aiohttp import web
from aiohttp.web import Response
from aiohttp_sse import sse_response
from datetime import datetimeasync def hello(request):
loop = request.app.loop
async with sse_response(request) as resp:
while True:
data = 'Server Time : {}'.format(datetime.now())
print(data)
await resp.send(data)
await asyncio.sleep(1)
return respasync def index(request):
d = """
var evtSource = new EventSource("/hello");
evtSource.onmessage = function(e) {
document.getElementById('response').innerText = e.data
}
Response from server:
"""
return Response(text=d, content_type='text/html')app = web.Application()
app.router.add_route('GET', '/hello', hello)
app.router.add_route('GET', '/', index)
web.run_app(app, host='127.0.0.1', port=8080)EventSource Protocol
--------------------* http://www.w3.org/TR/2011/WD-eventsource-20110310/
* https://developer.mozilla.org/en-US/docs/Server-sent_events/Using_server-sent_eventsRequirements
------------* Python_ 3.5+
* aiohttp_ 3+License
-------The *aiohttp-sse* is offered under Apache 2.0 license.
.. _Python: https://www.python.org
.. _asyncio: http://docs.python.org/3.5/library/asyncio.html
.. _aiohttp: https://github.com/aio-libs/aiohttp