import streamlit as st import pandas as pd from evaluation import evaluate_submission import os import datetime import sys # Make sure current directory includes parent of 'source' sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) LEADERBOARD_FILE = os.path.join(os.path.dirname(__file__), "..", "leaderboard.csv") st.title("🏆 Hackathon Leaderboard") uploaded_file = st.file_uploader("Upload your submission (.py)") if uploaded_file: temp_path = os.path.join(os.path.dirname(__file__), "submission_temp.py") with open(temp_path, "wb") as f: f.write(uploaded_file.read()) try: score = evaluate_submission(temp_path) # Implement this timestamp = datetime.datetime.now().isoformat() entry = {"filename": uploaded_file.name, "score": score, "timestamp": timestamp} # Save to leaderboard if os.path.exists(LEADERBOARD_FILE): df = pd.read_csv(LEADERBOARD_FILE) df = df.append(entry, ignore_index=True) else: df = pd.DataFrame([entry]) df.to_csv(LEADERBOARD_FILE, index=False) st.success(f"Submission scored {score}!") except Exception as e: st.error(f"Error: {e}") # Show leaderboard if os.path.exists(LEADERBOARD_FILE): df = pd.read_csv(LEADERBOARD_FILE) df = df.sort_values(by="score", ascending=False) st.subheader("🏅 Leaderboard") st.dataframe(df)