Skip to content

Commit

Permalink
Add better chat.py example.
Browse files Browse the repository at this point in the history
  • Loading branch information
zeekay committed Oct 25, 2016
1 parent 264998c commit b1d2c79
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
*.egg-info
*.pyc
dist/
build/
14 changes: 14 additions & 0 deletions 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
```
7 changes: 4 additions & 3 deletions 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

Expand All @@ -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)
3 changes: 3 additions & 0 deletions examples/chat/requirements.txt
@@ -0,0 +1,3 @@
bottle
gevent
gevent-websocket

0 comments on commit b1d2c79

Please sign in to comment.