diff options
Diffstat (limited to 'webapp/app/views.py')
| -rw-r--r-- | webapp/app/views.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/webapp/app/views.py b/webapp/app/views.py new file mode 100644 index 0000000..4aa2c05 --- /dev/null +++ b/webapp/app/views.py @@ -0,0 +1,37 @@ +from flask import render_template, request +from app import app, sio +import time + +import threading + +thread = None + +@app.route('/') +@app.route('/index') +def index(): + return render_template('index.html', + title='F16 Group1') + +connections = set() + +@sio.on('connect', namespace='/spawn') +def connect(sid, environ): + print("connect ", sid) + connections.add(sid) + +@sio.on('spawn', namespace='/spawn') +def message(sid, data): + print("message ", data) + +@sio.on('disconnect', namespace='/spawn') +def disconnect(sid): + print('disconnect', sid) + connections.remove(sid) + + + +def add_creature(): + time.sleep(5) + sio.emit('new creature', {'name': 'fish1'}, namespace='/spawn') + +thread = sio.start_background_task(add_creature) |
