File size: 1,481 Bytes
d22a7f8
475174a
 
 
bec9209
 
 
d22a7f8
bec9209
8fb7a79
 
 
bec9209
 
 
 
43bd9c2
8fb7a79
d7cb7b3
43bd9c2
d7cb7b3
 
 
 
 
 
43bd9c2
d7cb7b3
 
43bd9c2
 
475174a
d7cb7b3
43bd9c2
475174a
bec9209
 
43bd9c2
475174a
bec9209
 
 
 
 
 
 
 
 
 
 
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
50
51
import streamlit as st
import pandas as pd
import os
import datetime
import json
import gspread
from oauth2client.service_account import ServiceAccountCredentials

from data_upload import *

st.title("πŸ† Hackathon Leaderboard")

# ========================
# Submission Form
# ========================

uploaded_file = st.file_uploader("Upload your solution (.py)", type=["py"])

if uploaded_file:
    if st.button("Submit"):
        # Generate unique filename based on timestamp
        timestamp = datetime.datetime.now().isoformat()
        submission_filename = f"{timestamp.replace(':', '_')}_{uploaded_file.name}"
        submission_path = os.path.join("submissions", submission_filename)

        # Ensure submissions folder exists
        os.makedirs("submissions", exist_ok=True)

        # Save uploaded file
        with open(submission_path, "wb") as f:
            f.write(uploaded_file.read())

        # TODO: Add actual evaluation logic here
        score = 42  # Dummy score

        # Append to Google Sheet
        append_score(timestamp, score, submission_filename)
        st.success(f"Submission received! Score: {score}")

# ========================
# Show Leaderboard
# ========================
try:
    df = fetch_leaderboard()
    if not df.empty:
        df_sorted = df.sort_values(by="score", ascending=False)
        st.subheader("Leaderboard")
        st.dataframe(df_sorted)
except Exception as e:
    st.warning(f"Could not load leaderboard: {e}")