com3dian commited on
Commit
c05e0a4
Β·
verified Β·
1 Parent(s): f98657b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -37,11 +37,20 @@ def submit_file(event):
37
  return
38
 
39
  try:
 
 
40
  submission_path = os.path.join(temp_dir, filename)
 
 
 
 
 
 
41
  drive_file_id = upload_to_drive(submission_path, filename)
42
  status.object = f"βœ… Uploaded to Google Drive [File ID: {drive_file_id}]"
43
  except Exception as e:
44
  status.object = f"❌ Failed to upload to Google Drive: {e}"
 
45
 
46
  # Update leaderboard
47
  try:
 
37
  return
38
 
39
  try:
40
+ # Extract filename
41
+ filename = file_input.filename
42
  submission_path = os.path.join(temp_dir, filename)
43
+
44
+ # Save uploaded content to temp file
45
+ with open(submission_path, "wb") as f:
46
+ f.write(file_input.value)
47
+
48
+ # Upload to Google Drive
49
  drive_file_id = upload_to_drive(submission_path, filename)
50
  status.object = f"βœ… Uploaded to Google Drive [File ID: {drive_file_id}]"
51
  except Exception as e:
52
  status.object = f"❌ Failed to upload to Google Drive: {e}"
53
+ return # Exit early on failure
54
 
55
  # Update leaderboard
56
  try: