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)
### 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file bottle-websocket-0.2.7.tar.gz
.
File metadata
- Download URL: bottle-websocket-0.2.7.tar.gz
- Upload date:
- Size: 1.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57165c6ffc158e87401f560ab5cb81b7bb029c49b4869eacdeaae1a1569e7a68 |
|
MD5 | a2e0f610bebcaa951412cf35025e59a5 |
|
BLAKE2b-256 | f71ba4433f34fe3aa3d577f477506a8c15fc1f276e1ab12a0dbdb44baddfd572 |