Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -35,7 +35,7 @@ async def get_leaderboard_data():
|
|
35 |
sorted_scores = sorted(scores.items(), key=lambda x: x[1], reverse=True)
|
36 |
leaderboard_data = []
|
37 |
for rank, (uid, score) in enumerate(sorted_scores, start=1):
|
38 |
-
leaderboard_data.append((rank, uid, score))
|
39 |
print(f"Leaderboard data: {leaderboard_data}")
|
40 |
return leaderboard_data
|
41 |
except Exception as e:
|
@@ -44,9 +44,16 @@ async def get_leaderboard_data():
|
|
44 |
|
45 |
async def update_leaderboard_table():
|
46 |
leaderboard_data = await get_leaderboard_data()
|
47 |
-
return leaderboard_data
|
48 |
|
49 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
gr.Markdown("# Commune Leaderboard")
|
51 |
|
52 |
leaderboard_table = gr.components.Dataframe(
|
@@ -61,9 +68,7 @@ with gr.Blocks() as demo:
|
|
61 |
refresh_button.click(fn=update_leaderboard_table, outputs=leaderboard_table)
|
62 |
|
63 |
# Initial load of leaderboard data
|
64 |
-
|
65 |
-
leaderboard_data = loop.run_until_complete(get_leaderboard_data())
|
66 |
-
leaderboard_table.value = leaderboard_data
|
67 |
|
68 |
if __name__ == "__main__":
|
69 |
demo.launch()
|
|
|
35 |
sorted_scores = sorted(scores.items(), key=lambda x: x[1], reverse=True)
|
36 |
leaderboard_data = []
|
37 |
for rank, (uid, score) in enumerate(sorted_scores, start=1):
|
38 |
+
leaderboard_data.append((rank, uid, score))
|
39 |
print(f"Leaderboard data: {leaderboard_data}")
|
40 |
return leaderboard_data
|
41 |
except Exception as e:
|
|
|
44 |
|
45 |
async def update_leaderboard_table():
|
46 |
leaderboard_data = await get_leaderboard_data()
|
47 |
+
return gr.components.Dataframe.update(value=leaderboard_data)
|
48 |
|
49 |
+
with gr.Blocks(css="""
|
50 |
+
.gradio-dataframe {
|
51 |
+
width: 100%;
|
52 |
+
background-color: white;
|
53 |
+
font-size: 16px;
|
54 |
+
color: black;
|
55 |
+
}
|
56 |
+
""") as demo:
|
57 |
gr.Markdown("# Commune Leaderboard")
|
58 |
|
59 |
leaderboard_table = gr.components.Dataframe(
|
|
|
68 |
refresh_button.click(fn=update_leaderboard_table, outputs=leaderboard_table)
|
69 |
|
70 |
# Initial load of leaderboard data
|
71 |
+
demo.load(update_leaderboard_table, inputs=None, outputs=leaderboard_table)
|
|
|
|
|
72 |
|
73 |
if __name__ == "__main__":
|
74 |
demo.launch()
|