File size: 1,540 Bytes
d22a7f8
475174a
 
 
d22a7f8
43bd9c2
8fb7a79
 
 
43bd9c2
 
 
8fb7a79
43bd9c2
 
 
 
 
 
 
475174a
43bd9c2
 
475174a
43bd9c2
 
 
 
 
 
 
 
 
 
475174a
 
781e264
475174a
 
43bd9c2
 
 
475174a
 
 
 
43bd9c2
 
 
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
import streamlit as st
import pandas as pd
import os
import datetime

LEADERBOARD_FILE = "leaderboard.csv"

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

# User submission
uploaded_file = st.file_uploader("Upload your solution (.py)", type=["py"])
username = st.text_input("Enter your team name")

if uploaded_file and username:
    if st.button("Submit"):
        # Save uploaded file (optional)
        submission_path = f"submissions/{username}_{datetime.datetime.now().timestamp()}.py"
        os.makedirs("submissions", exist_ok=True)
        with open(submission_path, "wb") as f:
            f.write(uploaded_file.read())

        # TODO: Add your custom evaluation logic here
        score = 42  # Dummy score

        # Log entry
        timestamp = datetime.datetime.now().isoformat()
        entry = {
            "username": username,
            "timestamp": timestamp,
            "score": score,
            "file": os.path.basename(submission_path),
        }

        # Append to CSV
        if os.path.exists(LEADERBOARD_FILE):
            df = pd.read_csv(LEADERBOARD_FILE)
            df = pd.concat([df, pd.DataFrame([entry])], ignore_index=True)
        else:
            df = pd.DataFrame([entry])

        df.to_csv(LEADERBOARD_FILE, index=False)
        st.success(f"Submission received! Score: {score}")

# Show leaderboard
if os.path.exists(LEADERBOARD_FILE):
    df = pd.read_csv(LEADERBOARD_FILE)
    df_sorted = df.sort_values(by="score", ascending=False)
    st.subheader("Leaderboard")
    st.dataframe(df_sorted)