Skip to main content

WebSockets for bottle

Project description

This project adds websocket capabilities to [bottle](http://bottlepy.org), leveraging [gevent-websocket](http://www.gelens.org/code/gevent-websocket/) and [gevent](http://www.gevent.org/).

Usage is pretty straight-forward, just import the server and plugin:

from bottle.ext.websocket import GeventWebSocketServer
from bottle.ext.websocket import websocket

You can use the websocket plugin to turn routes websocket handlers, the websocket is passed to the route as the first argument:

@get('/websocket', apply=[websocket])
def echo(ws):
while True:
msg = ws.receive()
if msg is not None:
ws.send(msg)
else: break

And then use the provided server:

run(host='127.0.0.1', port=8080, server=GeventWebSocketServer)

Project details


Download files

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

Source Distribution

bottle-websocket-0.2.tar.gz (1.5 kB view details)

Uploaded Source

File details

Details for the file bottle-websocket-0.2.tar.gz.

File metadata

File hashes

Hashes for bottle-websocket-0.2.tar.gz
Algorithm Hash digest
SHA256 1e88e250c89cf5a024d5125ba4b6911adea7a519f63f5b37944af32e7ed66f9b
MD5 584f9628d0569b3be21aa8e3d3eebb8b
BLAKE2b-256 64a4a218c6fc88956f6cc238cb97a0b6e6899e42c72f87f10963c14f182e7776

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page