Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +20 -18
src/streamlit_app.py
CHANGED
@@ -13,35 +13,37 @@ st.title("🏆 Hackathon Leaderboard")
|
|
13 |
|
14 |
uploaded_file = st.file_uploader("Upload your solution (.py)", type=["py"])
|
15 |
|
16 |
-
if uploaded_file:
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
submission_path = os.path.join("submissions", submission_filename)
|
22 |
|
23 |
-
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
# ========================
|
38 |
-
# Show Leaderboard
|
39 |
# ========================
|
|
|
|
|
40 |
try:
|
41 |
df = fetch_leaderboard()
|
42 |
if not df.empty:
|
43 |
df_sorted = df.sort_values(by="score", ascending=False)
|
44 |
-
st.subheader("Leaderboard")
|
45 |
st.dataframe(df_sorted)
|
|
|
|
|
46 |
except Exception as e:
|
47 |
st.warning(f"Could not load leaderboard: {e}")
|
|
|
13 |
|
14 |
uploaded_file = st.file_uploader("Upload your solution (.py)", type=["py"])
|
15 |
|
16 |
+
if uploaded_file and st.button("Submit"):
|
17 |
+
# Generate unique filename based on timestamp
|
18 |
+
timestamp = datetime.datetime.now().isoformat()
|
19 |
+
submission_filename = f"{timestamp.replace(':', '_')}_{uploaded_file.name}"
|
20 |
+
submission_path = os.path.join("submissions", submission_filename)
|
|
|
21 |
|
22 |
+
# Ensure submissions folder exists
|
23 |
+
os.makedirs("submissions", exist_ok=True)
|
24 |
|
25 |
+
# Save uploaded file
|
26 |
+
with open(submission_path, "wb") as f:
|
27 |
+
f.write(uploaded_file.read())
|
28 |
|
29 |
+
# TODO: Add actual evaluation logic here
|
30 |
+
score = 42 # Dummy score
|
31 |
|
32 |
+
# Append to Google Sheet
|
33 |
+
append_score(timestamp, score, submission_filename)
|
34 |
+
st.success(f"Submission received! Score: {score}")
|
35 |
|
36 |
# ========================
|
37 |
+
# Always Show Leaderboard
|
38 |
# ========================
|
39 |
+
st.subheader("Leaderboard")
|
40 |
+
|
41 |
try:
|
42 |
df = fetch_leaderboard()
|
43 |
if not df.empty:
|
44 |
df_sorted = df.sort_values(by="score", ascending=False)
|
|
|
45 |
st.dataframe(df_sorted)
|
46 |
+
else:
|
47 |
+
st.info("No submissions yet.")
|
48 |
except Exception as e:
|
49 |
st.warning(f"Could not load leaderboard: {e}")
|