From 7d834b6e93ae414f64c5d5da7f1fcca3c0c4d141 Mon Sep 17 00:00:00 2001 From: Shan Shao <> Date: Sun, 7 Dec 2025 16:13:16 -0500 Subject: [PATCH] Show score increase and sort teams by score in realtime --- server.py | 3 ++- static/scoreboard.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 372a266c..737ebf20 100644 --- a/server.py +++ b/server.py @@ -50,7 +50,8 @@ def increase_score(): for team in scoreboard: if team["id"] == team_id: team["score"] += 1 - + # Re-sort the scoreboard after updating the score + scoreboard.sort(key=lambda t: t["score"], reverse=True) return jsonify(scoreboard=scoreboard) diff --git a/static/scoreboard.js b/static/scoreboard.js index 34ce2009..1b6a7493 100644 --- a/static/scoreboard.js +++ b/static/scoreboard.js @@ -32,7 +32,8 @@ function increase_score(id){ contentType: "application/json; charset=utf-8", data : JSON.stringify(team_id), success: function(result){ - + // Update the scoreboard with the new data + display_scoreboard(result.scoreboard); }, error: function(request, status, error){ console.log("Error");