Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Easy websockets for bottle.
Python
branch: master

Merge pull request #5 from quininer/patch-1

Compatible Python3-pip
latest commit fb8702b2b0
@zeekay authored
Failed to load latest commit information.
bottle_websocket 0.2.7
examples Add LICENSE.
.gitignore Add LICENSE.
.hgignore Added setup.py and echo server example
LICENSE Update LICENSE.
README.md Misspelled xeross.
requirements.txt Update requirements
setup.py Update setup.py

README.md

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

Something went wrong with that request. Please try again.