From ac05692c6a28f5092ba222bd4d13ec8ebcc796f5 Mon Sep 17 00:00:00 2001 From: Glitchy Date: Fri, 6 Jun 2025 20:52:42 +0000 Subject: [PATCH] nvm this fucked shit up --- app.py | 20 +++----------------- requirements.txt | 7 ------- static/note.js | 12 ------------ templates/note.html | 2 -- 4 files changed, 3 insertions(+), 38 deletions(-) diff --git a/app.py b/app.py index 8b61b5e..aaadef8 100644 --- a/app.py +++ b/app.py @@ -9,13 +9,10 @@ from flask_limiter import Limiter from flask_limiter.util import get_remote_address import time import re -from flask_socketio import SocketIO, emit - dotenv.load_dotenv() app = Flask(__name__) -socketio = SocketIO(app) app.secret_key = os.getenv("SECRET") USERS_FILE = "users.txt" DATA_DIR = "notes" @@ -130,7 +127,6 @@ def public_board(username): return f.read(), 200 if request.method == "POST": - if user != username: return "Forbidden", 403 data = request.get_json() @@ -139,34 +135,24 @@ def public_board(username): os.makedirs(os.path.dirname(path), exist_ok=True) with open(path, "w", encoding="utf-8") as f: f.write(data["content"]) - socketio.emit('board_update', {'content': data["content"]}) return jsonify({"status": "saved"}) -@socketio.on('connect') -def handle_connect(): - print('Client connected') - -@socketio.on('disconnect') -def handle_disconnect(): - print('Client disconnected') - -# When content is updated via POST /boardapi @app.route("/boardapi", methods=["GET", "POST"]) def shared_board(): path = os.path.join(DATA_DIR, "__shared_board.txt") + if request.method == "GET": if not os.path.exists(path): return "", 200 with open(path, "r", encoding="utf-8") as f: return f.read(), 200 - elif request.method == "POST": + + if request.method == "POST": data = request.get_json() if not data or "content" not in data: return "Bad request", 400 with open(path, "w", encoding="utf-8") as f: f.write(data["content"]) - # Broadcast new content to all clients - socketio.emit('board_update', {'content': data["content"]}) return jsonify({"status": "saved"}) diff --git a/requirements.txt b/requirements.txt index 8f566b2..0e22355 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -bidict==0.23.1 blinker==1.9.0 cffi==1.17.1 click==8.2.1 @@ -6,8 +5,6 @@ cryptography==45.0.3 Deprecated==1.2.18 Flask==3.1.1 Flask-Limiter==3.12 -Flask-SocketIO==5.5.1 -h11==0.16.0 itsdangerous==2.2.0 Jinja2==3.1.6 limits==5.2.0 @@ -19,11 +16,7 @@ packaging==25.0 pycparser==2.22 Pygments==2.19.1 python-dotenv==1.1.0 -python-engineio==4.12.2 -python-socketio==5.13.0 rich==13.9.4 -simple-websocket==1.1.0 typing_extensions==4.14.0 Werkzeug==3.1.3 wrapt==1.17.2 -wsproto==1.2.0 diff --git a/static/note.js b/static/note.js index 794392b..f2aa128 100644 --- a/static/note.js +++ b/static/note.js @@ -79,15 +79,3 @@ textarea.addEventListener("input", () => { } }, 500); }); - - -const socket = io(); - -// Listen for updates -socket.on('board_update', data => { - if (true && data.content !== last) { - textarea.value = data.content; - last = data.content; - status.textContent = "Updated from server"; - } -}); \ No newline at end of file diff --git a/templates/note.html b/templates/note.html index 6b41c13..281e5c9 100644 --- a/templates/note.html +++ b/templates/note.html @@ -16,9 +16,7 @@ - -