websocket – Websocket Server

This module provides a simple way to create a websocket server. It works with a few tweaks in the wsgi module that allow websockets to coexist with other WSGI applications.

To create a websocket server, simply decorate a handler method with WebSocketWSGI and use it as a wsgi application:

from evy.web import wsgi, websocket
import evy

def hello_world(ws):
    ws.send("hello world")

wsgi.server(evy.listen(('', 8090)), hello_world)

You can find a slightly more elaborate version of this code in the file examples/websocket.py.

As of version 0.9.13, evy.websocket supports SSL websockets; all that’s necessary is to use an SSL wsgi server.


The web socket spec is still under development, and it will be necessary to change the way that this module works in response to spec changes.

Related Topics

This Page