com3dian commited on
Commit
d7cb7b3
Β·
verified Β·
1 Parent(s): 43bd9c2

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +14 -11
src/streamlit_app.py CHANGED
@@ -7,31 +7,34 @@ LEADERBOARD_FILE = "leaderboard.csv"
7
 
8
  st.title("πŸ† Hackathon Leaderboard")
9
 
10
- # User submission
11
  uploaded_file = st.file_uploader("Upload your solution (.py)", type=["py"])
12
- username = st.text_input("Enter your team name")
13
 
14
- if uploaded_file and username:
15
  if st.button("Submit"):
16
- # Save uploaded file (optional)
17
- submission_path = f"submissions/{username}_{datetime.datetime.now().timestamp()}.py"
 
 
 
 
18
  os.makedirs("submissions", exist_ok=True)
 
 
19
  with open(submission_path, "wb") as f:
20
  f.write(uploaded_file.read())
21
 
22
- # TODO: Add your custom evaluation logic here
23
  score = 42 # Dummy score
24
 
25
- # Log entry
26
- timestamp = datetime.datetime.now().isoformat()
27
  entry = {
28
- "username": username,
29
  "timestamp": timestamp,
30
  "score": score,
31
- "file": os.path.basename(submission_path),
32
  }
33
 
34
- # Append to CSV
35
  if os.path.exists(LEADERBOARD_FILE):
36
  df = pd.read_csv(LEADERBOARD_FILE)
37
  df = pd.concat([df, pd.DataFrame([entry])], ignore_index=True)
 
7
 
8
  st.title("πŸ† Hackathon Leaderboard")
9
 
10
+ # Upload form
11
  uploaded_file = st.file_uploader("Upload your solution (.py)", type=["py"])
 
12
 
13
+ if uploaded_file:
14
  if st.button("Submit"):
15
+ # Generate unique filename based on timestamp
16
+ timestamp = datetime.datetime.now().isoformat()
17
+ submission_filename = f"{timestamp.replace(':', '_')}_{uploaded_file.name}"
18
+ submission_path = os.path.join("submissions", submission_filename)
19
+
20
+ # Ensure submissions folder exists
21
  os.makedirs("submissions", exist_ok=True)
22
+
23
+ # Save uploaded file
24
  with open(submission_path, "wb") as f:
25
  f.write(uploaded_file.read())
26
 
27
+ # TODO: Add actual evaluation logic here
28
  score = 42 # Dummy score
29
 
30
+ # Create leaderboard entry
 
31
  entry = {
 
32
  "timestamp": timestamp,
33
  "score": score,
34
+ "file": submission_filename,
35
  }
36
 
37
+ # Append to leaderboard.csv
38
  if os.path.exists(LEADERBOARD_FILE):
39
  df = pd.read_csv(LEADERBOARD_FILE)
40
  df = pd.concat([df, pd.DataFrame([entry])], ignore_index=True)