Spaces:
Sleeping
Sleeping
File size: 1,441 Bytes
abed169 475174a abed169 d22a7f8 abed169 f970fd2 8fb7a79 abed169 8fb7a79 abed169 d8e6110 abed169 326967b abed169 326967b abed169 e31cd27 abed169 10f2e01 8542abb 326967b abed169 8542abb abed169 326967b abed169 326967b abed169 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import streamlit as st
import pandas as pd
import os
import datetime
import dill as pickle
import inspect
from google_sheet import *
from google_drive import upload_to_drive
st.title("π Hackathon Leaderboard")
# ========================
# Submission Form
# ========================
import uuid
uploaded_file = st.file_uploader("Upload your submission (.zip)", type=["zip"], key=str(uuid.uuid4()))
if uploaded_file and st.button("Submit"):
timestamp = datetime.datetime.now().isoformat()
submission_filename = f"{timestamp.replace(':', '_')}_{uploaded_file.name}"
submission_path = os.path.join("submissions", submission_filename)
os.makedirs("submissions", exist_ok=True)
# Save uploaded file
with open(submission_path, "wb") as f:
f.write(uploaded_file.read())
try:
drive_file_id = upload_to_drive(submission_path, submission_filename)
st.success(f"Uploaded to Google Drive β
[File ID: {drive_file_id}]")
except Exception as e:
st.warning(f"Failed to upload to Google Drive: {e}")
# ========================
# Always Show Leaderboard
# ========================
st.subheader("Leaderboard")
try:
df = fetch_leaderboard()
if not df.empty:
df_sorted = df.sort_values(by="score", ascending=False)
st.dataframe(df_sorted)
else:
st.info("No submissions yet.")
except Exception as e:
st.warning(f"Could not load leaderboard: {e}")
|