diff --git a/app.py b/app.py index e7f6bd6..5fe6d4c 100644 --- a/app.py +++ b/app.py @@ -8,7 +8,6 @@ import jinja_partials from flask_htmx import HTMX import minify_html from urllib.parse import urlparse -from flask_socketio import SocketIO from db import DataBase from graph import generate_graph @@ -18,7 +17,6 @@ app = Flask(__name__) app.config['SECRET_KEY'] = 'secret!' jinja_partials.register_extensions(app) htmx = HTMX(app) -#socketio = SocketIO(app, cors_allowed_origins='*') db = DataBase(app) @@ -37,14 +35,6 @@ def response_minify(response): return response -# @socketio.on('message') -# def handle_message(data): -# current_time = datetime.now().replace( -# microsecond=0).isoformat() -# print('' + current_time + ' ' + json.dumps(data)) -# db.insert_cadence(data['rpm'], data['id']) - - @ app.route("/") def home(): return render_template('base.html') @@ -85,5 +75,4 @@ def cadence(): if __name__ == '__main__': # Bind to PORT if defined, otherwise default to 5000. port = int(os.environ.get('PORT', 5000)) - #socketio.run(app, host='127.0.0.1', port=port) app.run(host='127.0.0.1', port=port) diff --git a/requirements.txt b/requirements.txt index 351488c..54e9f0b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,8 +7,4 @@ flask-htmx==0.2.0 python-dateutil==2.8.2 minify-html==0.10.3 bidict==0.22.1 -flask-socketio==5.3.2 -python-engineio==4.3.4 -python-socketio==5.7.2 -eventlet==0.30.2 pygal==3.0.0 \ No newline at end of file diff --git a/static/js/BLE.js b/static/js/BLE.js index 82f07c8..e414a3f 100644 --- a/static/js/BLE.js +++ b/static/js/BLE.js @@ -1,4 +1,3 @@ -let socket = null; let characteristic = null; let prevRes = null; @@ -25,29 +24,8 @@ async function connect(props) { characteristic.addEventListener("characteristicvaluechanged", props.onChange); console.log("> Characteristic value changed event listener added"); - btn.classList.remove("bg-red-600"); + btn.classList.remove("bg-blue-600"); btn.classList.add("bg-green-600"); - /* - socket = io({ - reconnection: true, - reconnectionDelay: 1000, - reconnectionAttempts: 20, - forceNew: true, - }); - - socket.on("connect", () => { - btn.classList.remove("bg-red-600"); - btn.classList.add("bg-green-600"); - }); - - socket.on("disconnect", (reason) => { - if (reason === "io server disconnect") { - // the disconnection was initiated by the server, you need to reconnect manually - socket.connect(); - } - // else the socket will automatically try to reconnect - }); - */ } async function disconnect() { diff --git a/templates/base.html b/templates/base.html index 269ccbb..a5e7a53 100644 --- a/templates/base.html +++ b/templates/base.html @@ -54,7 +54,7 @@