import streamlit as st import pandas as pd import os import datetime LEADERBOARD_FILE = "leaderboard.csv" st.title("🏆 Hackathon Leaderboard") # Upload 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 # Create leaderboard entry entry = { "timestamp": timestamp, "score": score, "file": submission_filename, } # Append to leaderboard.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)