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)
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
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
bottle-websocket-0.2.tar.gz
(1.5 kB
view details)
File details
Details for the file bottle-websocket-0.2.tar.gz
.
File metadata
- Download URL: bottle-websocket-0.2.tar.gz
- Upload date:
- Size: 1.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e88e250c89cf5a024d5125ba4b6911adea7a519f63f5b37944af32e7ed66f9b |
|
MD5 | 584f9628d0569b3be21aa8e3d3eebb8b |
|
BLAKE2b-256 | 64a4a218c6fc88956f6cc238cb97a0b6e6899e42c72f87f10963c14f182e7776 |