rahul7star commited on
Commit
2b33705
·
verified ·
1 Parent(s): a76e4e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -229,7 +229,6 @@ def filter_and_rename_images(folder: str = Query("demo", description="Folder pat
229
  @app.post("/webhook-trigger")
230
  def call_other_space():
231
  try:
232
- # You can dynamically collect input from elsewhere too
233
  payload = {"input": "Start training from external trigger"}
234
 
235
  res = requests.post(
@@ -237,6 +236,17 @@ def call_other_space():
237
  json=payload,
238
  timeout=30,
239
  )
240
- return res.json()
 
 
 
 
 
 
 
 
 
 
 
241
  except Exception as e:
242
  return {"error": str(e)}
 
229
  @app.post("/webhook-trigger")
230
  def call_other_space():
231
  try:
 
232
  payload = {"input": "Start training from external trigger"}
233
 
234
  res = requests.post(
 
236
  json=payload,
237
  timeout=30,
238
  )
239
+
240
+ # ✅ check if response has content and is JSON
241
+ try:
242
+ data = res.json()
243
+ except ValueError:
244
+ return {
245
+ "error": f"Invalid JSON response. Status: {res.status_code}",
246
+ "text": res.text
247
+ }
248
+
249
+ return data
250
+
251
  except Exception as e:
252
  return {"error": str(e)}