triflix commited on
Commit
5664a58
·
verified ·
1 Parent(s): 1109a60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -38,10 +38,13 @@ def home(request: Request):
38
  async def upload(file: UploadFile = File(...)):
39
  try:
40
  dest = UPLOAD_DIR / f"{uuid.uuid4()}_{file.filename}"
 
41
  with dest.open("wb") as out:
42
- out.write(await file.read())
43
- # trigger immediate commit to HF dataset
44
- await scheduler.trigger()
 
 
45
  except Exception as e:
46
  raise HTTPException(500, f"Failed to store or push file: {e}")
47
 
 
38
  async def upload(file: UploadFile = File(...)):
39
  try:
40
  dest = UPLOAD_DIR / f"{uuid.uuid4()}_{file.filename}"
41
+ content = await file.read()
42
  with dest.open("wb") as out:
43
+ out.write(content)
44
+
45
+ # push in separate thread
46
+ await asyncio.to_thread(scheduler.trigger)
47
+
48
  except Exception as e:
49
  raise HTTPException(500, f"Failed to store or push file: {e}")
50