Update app.py
Browse files
app.py
CHANGED
|
@@ -54,23 +54,15 @@ def search_contacts(url: str) -> tuple[str, str]:
|
|
| 54 |
url = 'https://' + url
|
| 55 |
|
| 56 |
try:
|
| 57 |
-
#
|
| 58 |
-
|
| 59 |
-
'
|
| 60 |
}
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
"website": url,
|
| 65 |
-
"domain": url,
|
| 66 |
-
"search": url
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
# Make the API request using POST
|
| 70 |
-
response = requests.post(
|
| 71 |
API_ENDPOINT,
|
| 72 |
-
|
| 73 |
-
json=payload,
|
| 74 |
timeout=30
|
| 75 |
)
|
| 76 |
|
|
@@ -167,7 +159,7 @@ def format_contact_results(results: Dict[Any, Any], url: str) -> str:
|
|
| 167 |
Formatted string with contact information
|
| 168 |
"""
|
| 169 |
|
| 170 |
-
output = f"#
|
| 171 |
|
| 172 |
# Handle different possible result structures
|
| 173 |
if isinstance(results, dict):
|
|
@@ -184,7 +176,7 @@ def format_contact_results(results: Dict[Any, Any], url: str) -> str:
|
|
| 184 |
output += f"**Found {len(contacts)} contact(s):**\n\n"
|
| 185 |
|
| 186 |
for i, contact in enumerate(contacts, 1):
|
| 187 |
-
output += f"##
|
| 188 |
|
| 189 |
# Handle different contact field names
|
| 190 |
name = contact.get('name') or contact.get('full_name') or contact.get('contact_name') or "N/A"
|
|
@@ -216,16 +208,16 @@ def format_contact_results(results: Dict[Any, Any], url: str) -> str:
|
|
| 216 |
output += "---\n\n"
|
| 217 |
|
| 218 |
else:
|
| 219 |
-
output += "
|
| 220 |
|
| 221 |
elif isinstance(results, list):
|
| 222 |
if len(results) > 0:
|
| 223 |
output += f"**Found {len(results)} contact(s):**\n\n"
|
| 224 |
for i, contact in enumerate(results, 1):
|
| 225 |
-
output += f"##
|
| 226 |
output += f"{contact}\n\n"
|
| 227 |
else:
|
| 228 |
-
output += "
|
| 229 |
else:
|
| 230 |
output += f"**Result:** {results}\n\n"
|
| 231 |
|
|
@@ -235,11 +227,11 @@ def format_contact_results(results: Dict[Any, Any], url: str) -> str:
|
|
| 235 |
|
| 236 |
def create_sample_data():
|
| 237 |
"""Create sample data for demonstration"""
|
| 238 |
-
return '''#
|
| 239 |
|
| 240 |
**Found 2 contact(s):**
|
| 241 |
|
| 242 |
-
##
|
| 243 |
- **Name:** John Smith
|
| 244 |
- **Email:** john.smith@example.com
|
| 245 |
- **Title:** CEO
|
|
@@ -249,7 +241,7 @@ def create_sample_data():
|
|
| 249 |
|
| 250 |
---
|
| 251 |
|
| 252 |
-
##
|
| 253 |
- **Name:** Jane Doe
|
| 254 |
- **Email:** jane.doe@example.com
|
| 255 |
- **Title:** VP of Sales
|
|
@@ -305,7 +297,7 @@ with gr.Blocks(theme=theme, title="Contact Search - Kwekel Companies", css="""
|
|
| 305 |
# Header
|
| 306 |
gr.HTML("""
|
| 307 |
<div class="header">
|
| 308 |
-
<h1>
|
| 309 |
<p>Professional contact discovery powered by AI</p>
|
| 310 |
</div>
|
| 311 |
""")
|
|
@@ -313,7 +305,7 @@ with gr.Blocks(theme=theme, title="Contact Search - Kwekel Companies", css="""
|
|
| 313 |
# Info box
|
| 314 |
gr.HTML(f"""
|
| 315 |
<div class="info-box">
|
| 316 |
-
<h3>
|
| 317 |
<ol>
|
| 318 |
<li>Enter the website URL you want to search for contacts</li>
|
| 319 |
<li>Click "Search Contacts" to get results</li>
|
|
@@ -326,27 +318,27 @@ with gr.Blocks(theme=theme, title="Contact Search - Kwekel Companies", css="""
|
|
| 326 |
with gr.Row():
|
| 327 |
with gr.Column(scale=2):
|
| 328 |
url_input = gr.Textbox(
|
| 329 |
-
label="
|
| 330 |
placeholder="example.com or https://example.com",
|
| 331 |
info="Enter the website URL to search for contacts",
|
| 332 |
lines=1
|
| 333 |
)
|
| 334 |
|
| 335 |
with gr.Row():
|
| 336 |
-
search_btn = gr.Button("
|
| 337 |
-
demo_btn = gr.Button("
|
| 338 |
-
clear_btn = gr.Button("
|
| 339 |
|
| 340 |
with gr.Row():
|
| 341 |
with gr.Column(scale=1):
|
| 342 |
results_output = gr.Markdown(
|
| 343 |
-
label="
|
| 344 |
value="Enter a URL and click 'Search Contacts' to see results here."
|
| 345 |
)
|
| 346 |
|
| 347 |
with gr.Column(scale=1):
|
| 348 |
json_output = gr.Code(
|
| 349 |
-
label="
|
| 350 |
language="json",
|
| 351 |
value=""
|
| 352 |
)
|
|
|
|
| 54 |
url = 'https://' + url
|
| 55 |
|
| 56 |
try:
|
| 57 |
+
# Use GET request with URL parameter
|
| 58 |
+
params = {
|
| 59 |
+
'url': url
|
| 60 |
}
|
| 61 |
|
| 62 |
+
# Make the API request to the hardcoded endpoint using GET
|
| 63 |
+
response = requests.get(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
API_ENDPOINT,
|
| 65 |
+
params=params,
|
|
|
|
| 66 |
timeout=30
|
| 67 |
)
|
| 68 |
|
|
|
|
| 159 |
Formatted string with contact information
|
| 160 |
"""
|
| 161 |
|
| 162 |
+
output = f"# Contact Search Results for: {url}\n\n"
|
| 163 |
|
| 164 |
# Handle different possible result structures
|
| 165 |
if isinstance(results, dict):
|
|
|
|
| 176 |
output += f"**Found {len(contacts)} contact(s):**\n\n"
|
| 177 |
|
| 178 |
for i, contact in enumerate(contacts, 1):
|
| 179 |
+
output += f"## Contact {i}\n"
|
| 180 |
|
| 181 |
# Handle different contact field names
|
| 182 |
name = contact.get('name') or contact.get('full_name') or contact.get('contact_name') or "N/A"
|
|
|
|
| 208 |
output += "---\n\n"
|
| 209 |
|
| 210 |
else:
|
| 211 |
+
output += "No contacts found for this URL.\n\n"
|
| 212 |
|
| 213 |
elif isinstance(results, list):
|
| 214 |
if len(results) > 0:
|
| 215 |
output += f"**Found {len(results)} contact(s):**\n\n"
|
| 216 |
for i, contact in enumerate(results, 1):
|
| 217 |
+
output += f"## Contact {i}\n"
|
| 218 |
output += f"{contact}\n\n"
|
| 219 |
else:
|
| 220 |
+
output += "No contacts found for this URL.\n\n"
|
| 221 |
else:
|
| 222 |
output += f"**Result:** {results}\n\n"
|
| 223 |
|
|
|
|
| 227 |
|
| 228 |
def create_sample_data():
|
| 229 |
"""Create sample data for demonstration"""
|
| 230 |
+
return '''# Contact Search Results for: example.com
|
| 231 |
|
| 232 |
**Found 2 contact(s):**
|
| 233 |
|
| 234 |
+
## Contact 1
|
| 235 |
- **Name:** John Smith
|
| 236 |
- **Email:** john.smith@example.com
|
| 237 |
- **Title:** CEO
|
|
|
|
| 241 |
|
| 242 |
---
|
| 243 |
|
| 244 |
+
## Contact 2
|
| 245 |
- **Name:** Jane Doe
|
| 246 |
- **Email:** jane.doe@example.com
|
| 247 |
- **Title:** VP of Sales
|
|
|
|
| 297 |
# Header
|
| 298 |
gr.HTML("""
|
| 299 |
<div class="header">
|
| 300 |
+
<h1>Contact Search Tool</h1>
|
| 301 |
<p>Professional contact discovery powered by AI</p>
|
| 302 |
</div>
|
| 303 |
""")
|
|
|
|
| 305 |
# Info box
|
| 306 |
gr.HTML(f"""
|
| 307 |
<div class="info-box">
|
| 308 |
+
<h3>Instructions:</h3>
|
| 309 |
<ol>
|
| 310 |
<li>Enter the website URL you want to search for contacts</li>
|
| 311 |
<li>Click "Search Contacts" to get results</li>
|
|
|
|
| 318 |
with gr.Row():
|
| 319 |
with gr.Column(scale=2):
|
| 320 |
url_input = gr.Textbox(
|
| 321 |
+
label="Website URL",
|
| 322 |
placeholder="example.com or https://example.com",
|
| 323 |
info="Enter the website URL to search for contacts",
|
| 324 |
lines=1
|
| 325 |
)
|
| 326 |
|
| 327 |
with gr.Row():
|
| 328 |
+
search_btn = gr.Button("Search Contacts", variant="primary", scale=2)
|
| 329 |
+
demo_btn = gr.Button("Show Demo", variant="secondary", scale=1)
|
| 330 |
+
clear_btn = gr.Button("Clear", variant="secondary", scale=1)
|
| 331 |
|
| 332 |
with gr.Row():
|
| 333 |
with gr.Column(scale=1):
|
| 334 |
results_output = gr.Markdown(
|
| 335 |
+
label="Contact Results",
|
| 336 |
value="Enter a URL and click 'Search Contacts' to see results here."
|
| 337 |
)
|
| 338 |
|
| 339 |
with gr.Column(scale=1):
|
| 340 |
json_output = gr.Code(
|
| 341 |
+
label="Raw JSON Response",
|
| 342 |
language="json",
|
| 343 |
value=""
|
| 344 |
)
|