From 148f792a278a195191bc4825f253eef3a64998b9 Mon Sep 17 00:00:00 2001 From: Ken Cheng Date: Wed, 10 Dec 2025 16:46:22 -0500 Subject: [PATCH] Implement live scoreboard update and sorting --- server.py | 6 ++---- static/scoreboard.js | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server.py b/server.py index 372a266c..c26a660d 100644 --- a/server.py +++ b/server.py @@ -51,12 +51,10 @@ def increase_score(): if team["id"] == team_id: team["score"] += 1 + scoreboard = sorted(scoreboard, key=lambda team: team["score"], reverse=True) + return jsonify(scoreboard=scoreboard) if __name__ == '__main__': app.run(debug = True) - - - - diff --git a/static/scoreboard.js b/static/scoreboard.js index 34ce2009..a789aa4b 100644 --- a/static/scoreboard.js +++ b/static/scoreboard.js @@ -32,7 +32,9 @@ function increase_score(id){ contentType: "application/json; charset=utf-8", data : JSON.stringify(team_id), success: function(result){ - + if (result && result.scoreboard) { + display_scoreboard(result.scoreboard); + } }, error: function(request, status, error){ console.log("Error");