joshuadunlop commited on
Commit
0dbe372
·
verified ·
1 Parent(s): 91667e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -48,11 +48,17 @@ def get_backlinks(api_login, api_key, target_url, filters):
48
  if task_result and 'items' in task_result[0]:
49
  # The actual backlink items are nested within 'items'
50
  items = task_result[0]['items']
51
- st.text(f"First few items: {items[:5]}") # Debugging line to show the items structure
 
 
 
52
 
53
- # Convert to DataFrame
54
- df = pd.json_normalize(items)
55
- return df
 
 
 
56
  else:
57
  st.error("Received empty 'result' from API or missing 'items'.")
58
  return None
 
48
  if task_result and 'items' in task_result[0]:
49
  # The actual backlink items are nested within 'items'
50
  items = task_result[0]['items']
51
+
52
+ # Check if items is not None before accessing its elements
53
+ if items:
54
+ st.text(f"First few items: {items[:5]}") # Debugging line to show the items structure
55
 
56
+ # Convert to DataFrame
57
+ df = pd.json_normalize(items)
58
+ return df
59
+ else:
60
+ st.error("No items found in the API response.")
61
+ return None
62
  else:
63
  st.error("Received empty 'result' from API or missing 'items'.")
64
  return None