syedMohib44 commited on
Commit
81f4dce
Β·
1 Parent(s): e90608d
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -259,16 +259,20 @@ def gradio_upload(file):
259
  return "No file selected."
260
 
261
  try:
262
- content = str(file) # Works for NamedString
263
  import requests
264
 
265
  base_url = os.getenv("HF_SPACE_URL", "http://localhost:7860")
266
- response = requests.post(f"{base_url}/upload/", json={"content": content})
 
 
 
 
267
 
268
  if response.status_code == 200:
269
  return "βœ… Data successfully uploaded and indexed!"
270
  else:
271
  return f"❌ Failed: {response.text}"
 
272
  except Exception as e:
273
  return f"❌ Error: {str(e)}"
274
 
 
259
  return "No file selected."
260
 
261
  try:
 
262
  import requests
263
 
264
  base_url = os.getenv("HF_SPACE_URL", "http://localhost:7860")
265
+
266
+ # Open the file as binary
267
+ with open(file.name, "rb") as f:
268
+ files = {"file": (file.name, f, file.type)}
269
+ response = requests.post(f"{base_url}/upload/", files=files)
270
 
271
  if response.status_code == 200:
272
  return "βœ… Data successfully uploaded and indexed!"
273
  else:
274
  return f"❌ Failed: {response.text}"
275
+
276
  except Exception as e:
277
  return f"❌ Error: {str(e)}"
278