JayBene1 commited on
Commit
df1fc4e
·
verified ·
1 Parent(s): 5d45738

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -54,9 +54,12 @@ def search_contacts(url: str) -> tuple[str, str]:
54
  url = 'https://' + url
55
 
56
  try:
57
- # Prepare the API request - using GET with URL parameter
58
  params = {
59
- 'url': url
 
 
 
60
  }
61
 
62
  # Make the API request to the hardcoded endpoint using GET
@@ -70,6 +73,9 @@ def search_contacts(url: str) -> tuple[str, str]:
70
  try:
71
  result = response.json()
72
 
 
 
 
73
  # Hugging Face Spaces API returns data in a different format
74
  if isinstance(result, dict) and 'data' in result:
75
  actual_result = result['data'][0] if result['data'] else {}
@@ -78,6 +84,14 @@ def search_contacts(url: str) -> tuple[str, str]:
78
 
79
  # Format the results for display
80
  formatted_output = format_contact_results(actual_result, url)
 
 
 
 
 
 
 
 
81
  raw_json = json.dumps(result, indent=2)
82
 
83
  return formatted_output, raw_json
 
54
  url = 'https://' + url
55
 
56
  try:
57
+ # Try different parameter names that might work
58
  params = {
59
+ 'url': url,
60
+ 'website': url,
61
+ 'domain': url,
62
+ 'search': url
63
  }
64
 
65
  # Make the API request to the hardcoded endpoint using GET
 
73
  try:
74
  result = response.json()
75
 
76
+ # Add debugging info
77
+ request_url = f"{API_ENDPOINT}?url={url}"
78
+
79
  # Hugging Face Spaces API returns data in a different format
80
  if isinstance(result, dict) and 'data' in result:
81
  actual_result = result['data'][0] if result['data'] else {}
 
84
 
85
  # Format the results for display
86
  formatted_output = format_contact_results(actual_result, url)
87
+
88
+ # Add debugging info to the formatted output
89
+ debug_info = f"\n\n**Debug Info:**\n"
90
+ debug_info += f"- Request URL: {request_url}\n"
91
+ debug_info += f"- Response contains {len(actual_result) if isinstance(actual_result, list) else 'N/A'} items\n"
92
+ debug_info += f"- First few keys: {list(actual_result.keys())[:5] if isinstance(actual_result, dict) else 'N/A'}\n"
93
+
94
+ formatted_output += debug_info
95
  raw_json = json.dumps(result, indent=2)
96
 
97
  return formatted_output, raw_json