Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +21 -23
src/streamlit_app.py
CHANGED
@@ -2,12 +2,18 @@ import streamlit as st
|
|
2 |
import pandas as pd
|
3 |
import os
|
4 |
import datetime
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
|
8 |
st.title("π Hackathon Leaderboard")
|
9 |
|
10 |
-
#
|
|
|
|
|
|
|
11 |
uploaded_file = st.file_uploader("Upload your solution (.py)", type=["py"])
|
12 |
|
13 |
if uploaded_file:
|
@@ -27,26 +33,18 @@ if uploaded_file:
|
|
27 |
# TODO: Add actual evaluation logic here
|
28 |
score = 42 # Dummy score
|
29 |
|
30 |
-
#
|
31 |
-
|
32 |
-
"timestamp": timestamp,
|
33 |
-
"score": score,
|
34 |
-
"file": submission_filename,
|
35 |
-
}
|
36 |
-
|
37 |
-
# Append to leaderboard.csv
|
38 |
-
if os.path.exists(LEADERBOARD_FILE):
|
39 |
-
df = pd.read_csv(LEADERBOARD_FILE)
|
40 |
-
df = pd.concat([df, pd.DataFrame([entry])], ignore_index=True)
|
41 |
-
else:
|
42 |
-
df = pd.DataFrame([entry])
|
43 |
-
|
44 |
-
df.to_csv(LEADERBOARD_FILE, index=False)
|
45 |
st.success(f"Submission received! Score: {score}")
|
46 |
|
47 |
-
#
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import pandas as pd
|
3 |
import os
|
4 |
import datetime
|
5 |
+
import json
|
6 |
+
import gspread
|
7 |
+
from oauth2client.service_account import ServiceAccountCredentials
|
8 |
|
9 |
+
from data_upload import *
|
10 |
|
11 |
st.title("π Hackathon Leaderboard")
|
12 |
|
13 |
+
# ========================
|
14 |
+
# Submission Form
|
15 |
+
# ========================
|
16 |
+
|
17 |
uploaded_file = st.file_uploader("Upload your solution (.py)", type=["py"])
|
18 |
|
19 |
if uploaded_file:
|
|
|
33 |
# TODO: Add actual evaluation logic here
|
34 |
score = 42 # Dummy score
|
35 |
|
36 |
+
# Append to Google Sheet
|
37 |
+
append_score(timestamp, score, submission_filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
st.success(f"Submission received! Score: {score}")
|
39 |
|
40 |
+
# ========================
|
41 |
+
# Show Leaderboard
|
42 |
+
# ========================
|
43 |
+
try:
|
44 |
+
df = fetch_leaderboard()
|
45 |
+
if not df.empty:
|
46 |
+
df_sorted = df.sort_values(by="score", ascending=False)
|
47 |
+
st.subheader("Leaderboard")
|
48 |
+
st.dataframe(df_sorted)
|
49 |
+
except Exception as e:
|
50 |
+
st.warning(f"Could not load leaderboard: {e}")
|