Remove all references to socket.io

This commit is contained in:
Peter Stockings
2023-01-26 22:12:51 +11:00
parent 5a30278aaa
commit 08753c8bfe
4 changed files with 2 additions and 42 deletions

11
app.py
View File

@@ -8,7 +8,6 @@ import jinja_partials
from flask_htmx import HTMX from flask_htmx import HTMX
import minify_html import minify_html
from urllib.parse import urlparse from urllib.parse import urlparse
from flask_socketio import SocketIO
from db import DataBase from db import DataBase
from graph import generate_graph from graph import generate_graph
@@ -18,7 +17,6 @@ app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!' app.config['SECRET_KEY'] = 'secret!'
jinja_partials.register_extensions(app) jinja_partials.register_extensions(app)
htmx = HTMX(app) htmx = HTMX(app)
#socketio = SocketIO(app, cors_allowed_origins='*')
db = DataBase(app) db = DataBase(app)
@@ -37,14 +35,6 @@ def response_minify(response):
return 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("/") @ app.route("/")
def home(): def home():
return render_template('base.html') return render_template('base.html')
@@ -85,5 +75,4 @@ def cadence():
if __name__ == '__main__': if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000. # Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 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) app.run(host='127.0.0.1', port=port)

View File

@@ -7,8 +7,4 @@ flask-htmx==0.2.0
python-dateutil==2.8.2 python-dateutil==2.8.2
minify-html==0.10.3 minify-html==0.10.3
bidict==0.22.1 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 pygal==3.0.0

View File

@@ -1,4 +1,3 @@
let socket = null;
let characteristic = null; let characteristic = null;
let prevRes = null; let prevRes = null;
@@ -25,29 +24,8 @@ async function connect(props) {
characteristic.addEventListener("characteristicvaluechanged", props.onChange); characteristic.addEventListener("characteristicvaluechanged", props.onChange);
console.log("> Characteristic value changed event listener added"); 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"); 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() { async function disconnect() {

View File

@@ -54,7 +54,7 @@
</div> </div>
</div> </div>
<button <button
class="p-0 w-16 h-16 bg-red-600 rounded-full hover:bg-red-700 active:shadow-lg mouse shadow transition ease-in duration-200 focus:outline-none" class="fixed z-90 bottom-10 right-8 bg-blue-600 w-20 h-20 rounded-full drop-shadow-lg flex justify-center items-center text-white text-4xl hover:bg-blue-700 hover:drop-shadow-2xl hover:animate-bounce duration-300"
id="ble-connect"> id="ble-connect">
<svg viewBox="0 0 20 20" enable-background="new 0 0 20 20" class="w-6 h-6 inline-block"> <svg viewBox="0 0 20 20" enable-background="new 0 0 20 20" class="w-6 h-6 inline-block">
<path fill="#FFFFFF" d="M16,10c0,0.553-0.048,1-0.601,1H11v4.399C11,15.951,10.553,16,10,16c-0.553,0-1-0.049-1-0.601V11H4.601 <path fill="#FFFFFF" d="M16,10c0,0.553-0.048,1-0.601,1H11v4.399C11,15.951,10.553,16,10,16c-0.553,0-1-0.049-1-0.601V11H4.601
@@ -65,9 +65,6 @@
</main> </main>
</div> </div>
<script src="/static/js/BLE.js"></script> <script src="/static/js/BLE.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.5.4/socket.io.min.js"
integrity="sha512-HTENHrkQ/P0NGDFd5nk6ibVtCkcM7jhr2c7GyvXp5O+4X6O5cQO9AhqFzM+MdeBivsX7Hoys2J7pp2wdgMpCvw=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</body> </body>
</html> </html>