Skip to main content

Asynchronous WSGI and WebSocket server based on asyncore module

Project description

This is a single-threaded asynchronous WSGI server with WebSockets support based on asyncore module. It should be compatible with Python 2.7 and 3.

Example:

from from wsgiref.simple_server import demo_app
from asyncore_wsgi import AsyncWebSocketHandler, make_server


class SimpleEchoHandler(AsyncWebSocketHandler):

    def handleMessage(self):
        print('Received WebSocket message: {}'.format(self.data))
        self.sendMessage(self.data)

    def handleConnected(self):
        print('WebSocket connected')

    def handleClose(self):
        print('WebSocket closed')


httpd = make_server('', 8000, demo_app, ws_handler_class=SimpleEchoHandler)
httpd.serve_forever()

The server in the preceding example serves a demo WSGI app from the Standard Library and the echo WebSocket handler on '/ws' path.

WebSocket part was borrowed from this project.

License

MIT, see LICENSE.txt

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for asyncore-wsgi, version 0.0.9
Filename, size File type Python version Upload date Hashes
Filename, size asyncore_wsgi-0.0.9-py2.py3-none-any.whl (10.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size asyncore-wsgi-0.0.9.tar.gz (10.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page