bw
bottle-websocket
pypi i bottle-websocket
bw

bottle-websocket

🍾 Easy websockets for bottle.

by Z

0.2.9 (see all)License:MIT
pypi i bottle-websocket
Readme

This project adds websocket capabilities to bottle, leveraging gevent-websocket and gevent.

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

VersionTagPublished
0.2.9
8yrs ago
0.2.8
9yrs ago
0.2.7
9yrs ago
0.2.6
9yrs ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate