diff --git a/.gitignore b/.gitignore index 0c31ad1..bc7ddb9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.egg-info +*.pyc dist/ build/ diff --git a/examples/chat/README.md b/examples/chat/README.md new file mode 100644 index 0000000..73b98ed --- /dev/null +++ b/examples/chat/README.md @@ -0,0 +1,14 @@ +# Chat Example +Simple chat example. + +## Install +Install dependencies: +```bash +$ pip install -r requirements.txt +``` + +## Usage +Run the server: +```bash +$ python chat.py +``` diff --git a/examples/chat/chat.py b/examples/chat/chat.py index de45eea..1930cb8 100644 --- a/examples/chat/chat.py +++ b/examples/chat/chat.py @@ -1,4 +1,4 @@ -from bottle import default_app, get, template +from bottle import get, template, run from bottle.ext.websocket import GeventWebSocketServer from bottle.ext.websocket import websocket @@ -16,7 +16,8 @@ def chat(ws): if msg is not None: for u in users: u.send(msg) - else: break + else: + break users.remove(ws) -application = default_app() +run(host='127.0.0.1', port=8080, server=GeventWebSocketServer) diff --git a/examples/chat/requirements.txt b/examples/chat/requirements.txt new file mode 100644 index 0000000..771efa6 --- /dev/null +++ b/examples/chat/requirements.txt @@ -0,0 +1,3 @@ +bottle +gevent +gevent-websocket