From 1a1cfc5ffdf41165df3c50db2ea6e8c4408b2a25 Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Tue, 3 Jan 2023 11:41:27 +1100 Subject: [PATCH] esp32 is taking 2-3s for TLS negotiation, try switching from https to wss --- app.py | 9 ++++++++- requirements.txt | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index b67f622..b31bb69 100644 --- a/app.py +++ b/app.py @@ -8,10 +8,12 @@ import jinja_partials from flask_htmx import HTMX import minify_html from urllib.parse import urlparse +from flask_socketio import SocketIO app = Flask(__name__) jinja_partials.register_extensions(app) htmx = HTMX(app) +socketio = SocketIO(app) @app.after_request @@ -29,6 +31,11 @@ def response_minify(response): return response +@socketio.on('message') +def handle_message(data): + print('received message: ' + data) + + @app.route("/api/status", methods=['GET', 'POST']) def status(): req_data = save_request(request) @@ -49,4 +56,4 @@ def save_request(request): if __name__ == '__main__': # Bind to PORT if defined, otherwise default to 5000. port = int(os.environ.get('PORT', 5000)) - app.run(host='127.0.0.1', port=port) + socketio.run(app, host='127.0.0.1', port=port) diff --git a/requirements.txt b/requirements.txt index ac809cc..a02d961 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,8 @@ jinja-partials==0.1.1 psycopg2-binary==2.9.3 flask-htmx==0.2.0 python-dateutil==2.8.2 -minify-html==0.10.3 \ No newline at end of file +minify-html==0.10.3 +bidict==0.22.1 +flask-socketio==5.3.2 +python-engineio==4.3.4 +python-socketio==5.7.2 \ No newline at end of file