From ce4842d93e6dfb09c7f7de2f1565017975baf7ea Mon Sep 17 00:00:00 2001 From: Petr Kracik Date: Fri, 5 Jun 2020 16:14:56 +0200 Subject: [PATCH] SocketIO: test --- runsockettest.sh | 1 + socketiotest.py | 19 +++++++++++++++++++ templates/socketio.html | 14 ++++++++++++++ 3 files changed, 34 insertions(+) create mode 100755 runsockettest.sh create mode 100644 socketiotest.py create mode 100644 templates/socketio.html diff --git a/runsockettest.sh b/runsockettest.sh new file mode 100755 index 0000000..4c5fa1d --- /dev/null +++ b/runsockettest.sh @@ -0,0 +1 @@ +uwsgi --http :8001 --gevent 1000 --http-websockets --master --wsgi-file socketiotest.py --callable app diff --git a/socketiotest.py b/socketiotest.py new file mode 100644 index 0000000..9857b52 --- /dev/null +++ b/socketiotest.py @@ -0,0 +1,19 @@ +from flask import Flask, render_template +from flask_socketio import SocketIO + +app = Flask(__name__) +socketio = SocketIO(app) + +@app.route("/") +def index(): + return render_template("socketio.html") + + +@socketio.on('my event') +def handle_my_custom_event(json): + print('received json: ' + str(json)) + + +if __name__ == '__main__': + socketio.run(host="0.0.0.0", port=8001, app=app) + diff --git a/templates/socketio.html b/templates/socketio.html new file mode 100644 index 0000000..19181e9 --- /dev/null +++ b/templates/socketio.html @@ -0,0 +1,14 @@ + + + + + +ahoj3 + + +