From dfe1127addf7e31acd63e87db0a5d5e35628ea67 Mon Sep 17 00:00:00 2001 From: group1 Date: Sun, 9 Oct 2016 14:45:03 -0400 Subject: Add twinkle --- webapp/app/views.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 webapp/app/views.py (limited to 'webapp/app/views.py') 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) -- cgit v1.3.1