nikhilyadavtemp1 commited on
Commit
412c1dd
·
1 Parent(s): 8fc4b59

feat: add super-simple /u endpoint for easier CLI uploads

Browse files
Files changed (1) hide show
  1. main.py +13 -0
main.py CHANGED
@@ -38,6 +38,19 @@ app.mount("/static", StaticFiles(directory="static"), name="static")
38
  async def read_index():
39
  return FileResponse("static/index.html")
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  @app.post("/upload")
42
  async def upload_files(
43
  files: List[UploadFile] = File(...),
 
38
  async def read_index():
39
  return FileResponse("static/index.html")
40
 
41
+ @app.post("/u")
42
+ async def easy_upload(file: UploadFile = File(...)):
43
+ # Super simple endpoint for one-line curl
44
+ file_id = str(uuid.uuid4())[:8]
45
+ filename = f"cli_{file_id}_{file.filename}"
46
+ file_path = os.path.join(UPLOAD_DIR, filename)
47
+
48
+ with open(file_path, "wb") as buffer:
49
+ shutil.copyfileobj(file.file, buffer)
50
+
51
+ # Return JUST the raw URL for easy terminal piping
52
+ return f"https://ttnikal-filesharing.hf.space/download/{filename}\n"
53
+
54
  @app.post("/upload")
55
  async def upload_files(
56
  files: List[UploadFile] = File(...),