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/).

### Install
Use `pip` or `easy_install`:

pip install bottle-websocket

### Usage
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)

### Contributors
- [zeekay](https://github.com/zeekay)
- [xeross](https://github.com/xeross)

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.9.tar.gz (2.0 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for bottle-websocket-0.2.9.tar.gz
Algorithm Hash digest
SHA256 9887f70dc0c7592ed8d0d11a14aa95dede6cd08d50d83d5b81fd963e5fec738b
MD5 a66a85716b407535243b234b9b7fd67f
BLAKE2b-256 178ea22666b4bb0a6e31de579504077df2b1c2f1438136777c728e6cfabef295

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