diff --git a/server.py b/server.py index 372a266c..a6c3962f 100644 --- a/server.py +++ b/server.py @@ -50,7 +50,9 @@ def increase_score(): for team in scoreboard: if team["id"] == team_id: team["score"] += 1 - + + #sort by score: + scoreboard.sort(key=lambda x: x["score"], reverse=True) return jsonify(scoreboard=scoreboard) diff --git a/static/scoreboard.js b/static/scoreboard.js index 34ce2009..d5bd7fff 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){ - + //increase score if the button is pressed + display_scoreboard(result.scoreboard); }, error: function(request, status, error){ console.log("Error");