Skip to content

Instantly share code, notes, and snippets.

@bwhite
Forked from colegleason/server.py
Last active Dec 27, 2015
Embed
What would you like to do?
import gevent.monkey
gevent.monkey.patch_all()
import msgpack
from gevent import pywsgi
from geventwebsocket.handler import WebSocketHandler
def websocket_app(environ, start_response):
print('Connected')
if environ["PATH_INFO"] == '/':
ws = environ["wsgi.websocket"]
while 1:
msg_data = ws.receive()
msg = msgpack.loads(msg_data)
print(msg)
pywsgi.WSGIServer(("", 8080), websocket_app,
handler_class=WebSocketHandler).serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment