Update app.py
Browse files12345678206 unmodified lines21521621721821922011 unmodified lines23223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841925 unmodified lines4454464474484494504514524534544554564574584594604614624634644654664674684694704714727 unmodified lines4804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195202 unmodified lines523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724import gradio as grimport requestsimport reimport jsonimport csvimport iofrom urllib.parse import urlparse, urljoinimport time206 unmodified linesdef extract_domain(url):"""Extract domain from URL"""try:if not url.startswith(('http://', 'https://')):url = 'https://' + urlparsed = urlparse(url)11 unmodified linesif not target_domain:return []print(f"Searching for domain: {target_domain}") # Debug infomatching_contacts = []for contact in CONTACTS_DB:contact_domain = extract_domain(contact['website'])print(f"Comparing with: {contact_domain}") # Debug info# Exact domain match or subdomain matchif target_domain == contact_domain or target_domain in contact_domain or contact_domain in target_domain:matching_contacts.append(contact)print(f"Found {len(matching_contacts)} matching contacts") # Debug inforeturn matching_contactsdef simulate_website_scraping(url):"""Simulate scraping a website and finding contact information"""# Add some delay to simulate real scrapingtime.sleep(random.uniform(0.5, 1))# Find matching contacts from our databasecontacts = find_contacts_by_website(url)return contactsdef parse_csv_file(file_content):"""Parse CSV file and extract website URLs"""websites = []try:# Decode file contentcontent = file_content.decode('utf-8')# Parse CSVcsv_reader = csv.DictReader(io.StringIO(content))# Look for common website column names (case-insensitive)website_columns = ['website', 'url', 'domain', 'site', 'web', 'homepage']# Get all column names and print for debuggingall_columns = list(csv_reader.fieldnames) if csv_reader.fieldnames else []print(f"CSV columns found: {all_columns}")# Find the website column (case-insensitive)website_column = Nonefor col_name in all_columns:if col_name and col_name.lower().strip() in website_columns:website_column = col_nameprint(f"Using website column: '{website_column}'")breakif not website_column:print(f"No website column found. Available columns: {all_columns}")return []# Extract websitesfor row in csv_reader:website_url = row.get(website_column, '').strip()if website_url:websites.append(website_url)print(f"Extracted {len(websites)} websites: {websites[:5]}...") # Show first 5return websitesexcept Exception as e:print(f"Error parsing CSV: {e}")return []def search_csv_websites(csv_file, max_results=10):"""Search for contacts from websites listed in CSV file"""if csv_file is None:return "Please upload a CSV file", ""try:# Parse CSV filewebsites = parse_csv_file(csv_file)if not websites:return "No websites found in CSV file. Please ensure your CSV has a column named 'website', 'url', or 'domain'. Check the console for debugging info about your CSV columns.", ""all_contacts = []processed_websites = []# Search each websitefor website in websites[:20]: # Limit to first 20 websitesprint(f"Processing website: {website}")contacts = simulate_website_scraping(website)if contacts:all_contacts.extend(contacts)processed_websites.append(website)print(f"Found {len(contacts)} contacts for {website}")else:print(f"No contacts found for {website}")# Remove duplicates based on emailunique_contacts = []seen_emails = set()for contact in all_contacts:if contact['email'] not in seen_emails:unique_contacts.append(contact)seen_emails.add(contact['email'])# Limit resultsunique_contacts = unique_contacts[:max_results]if not unique_contacts:return f"No contacts found for the {len(websites)} websites in the CSV file. Processed websites: {', '.join(websites[:10])}", ""# Format resultsresults_text = f"CONTACT DISCOVERY REPORT\n"results_text += f"Websites Processed: {len(processed_websites)}\n"results_text += f"Total Websites in CSV: {len(websites)}\n"results_text += f"Websites with Contacts: {len(processed_websites)}\n"results_text += f"Unique Contacts Found: {len(unique_contacts)}\n"results_text += f"Processed Websites: {', '.join(processed_websites)}\n"results_text += f"{'='*60}\n\n"for i, contact in enumerate(unique_contacts, 1):results_text += f"CONTACT #{i}\n"results_text += f"Name: {contact['first_name']} {contact['last_name']}\n"results_text += f"Position: {contact['job_title']}\n"results_text += f"Email: {contact['email']}\n"results_text += f"Phone: {contact['phone']}\n"results_text += f"Company: {contact['company']}\n"results_text += f"Website: {contact['website']}\n\n"# Create CSV outputcsv_output = "First Name,Last Name,Job Title,Email,Phone,Company,Website\n"for contact in unique_contacts:csv_output += f"{contact['first_name']},{contact['last_name']},{contact['job_title']},{contact['email']},{contact['phone']},{contact['company']},{contact['website']}\n"return results_text, csv_outputexcept Exception as e:return f"Error processing CSV file: {str(e)}", ""def search_website_contacts(website_url, max_results=10):"""Main function to search for contacts on a website"""if not website_url:return "Please enter a website URL", ""# Clean up URLif not website_url.startswith(('http://', 'https://')):website_url = 'https://' + website_urltry:# Simulate finding contactscontacts = simulate_website_scraping(website_url)if not contacts:return f"No contacts found on {website_url}. \n\nThis website is not in our contact database. Try one of the sample websites listed below, or the website might not have publicly available contact information.", ""# Limit resultscontacts = contacts[:max_results]# Format resultsresults_text = f"CONTACT INTELLIGENCE REPORT\n"results_text += f"Website: {website_url}\n"results_text += f"Contacts Found: {len(contacts)}\n"results_text += f"{'='*60}\n\n"for i, contact in enumerate(contacts, 1):results_text += f"CONTACT #{i}\n"results_text += f"First Name: {contact['first_name']}\n"results_text += f"Last Name: {contact['last_name']}\n"results_text += f"Position: {contact['job_title']}\n"results_text += f"Email: {contact['email']}\n"results_text += f"Phone: {contact['phone']}\n"results_text += f"Company: {contact['company']}\n\n"# Create a simple table format for the second outputtable_text = "First Name,Last Name,Job Title,Email,Phone,Company\n"for contact in contacts:table_text += f"{contact['first_name']},{contact['last_name']},{contact['job_title']},{contact['email']},{contact['phone']},{contact['company']}\n"return results_text, table_textexcept Exception as e:return f"Error searching website: {str(e)}", ""def get_all_available_websites():"""Get list of all available websites from the database"""websites = list(set([contact['website'] for contact in CONTACTS_DB]))return "\n".join(sorted(websites))# Custom CSScustom_css = """25 unmodified linesopacity: 0.9;}.corporate-card {background: white;border: 1px solid #d1d5db;border-radius: 12px;padding: 25px;margin: 15px 0;box-shadow: 0 4px 15px rgba(0,0,0,0.1);border-left: 5px solid #1e40af;}.tips-section {background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);border: 2px solid #cbd5e1;border-radius: 15px;padding: 20px;margin: 10px 0;}.tips-section h3 {color: #1e40af;margin-top: 0;font-weight: 600;}.primary-btn {7 unmodified linestransition: all 0.3s ease;}.primary-btn:hover {background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);transform: translateY(-2px);box-shadow: 0 6px 20px rgba(30, 64, 175, 0.4);}.secondary-btn {background: white;color: #374151;border: 2px solid #d1d5db;border-radius: 6px;padding: 8px 16px;font-weight: 500;transition: all 0.3s ease;}.secondary-btn:hover {border-color: #1e40af;color: #1e40af;background: #f8fafc;}.custom-input {border: 2px solid #d1d5db;border-radius: 8px;padding: 12px;font-size: 16px;transition: border-color 0.3s ease;}.custom-input:focus {border-color: #3b82f6;box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);}.results-container {background: white;border: 1px solid #e5e7eb;2 unmodified linesmargin: 15px 0;box-shadow: 0 2px 10px rgba(0,0,0,0.05);}.section-header {background: linear-gradient(135deg, #64748b 0%, #475569 100%);color: white;padding: 15px 20px;border-radius: 10px;margin: 20px 0 15px 0;font-weight: 600;}"""# Create Gradio interfacewith gr.Blocks(css=custom_css, title="Contact Discovery Platform", theme=gr.themes.Base()) as app:gr.HTML("""<div class="main-header"><h1>Contact Discovery Platform</h1><p>Professional Contact Discovery & Lead Generation Tool</p><p style="font-size: 0.95em; opacity: 0.8;">Advanced website analysis for contact intelligence gathering</p></div>""")with gr.Tabs():# Single Website Search Tabwith gr.TabItem("Single Website Search"):with gr.Row():with gr.Column(scale=2):gr.HTML('<div class="section-header">Search Parameters</div>')website_input = gr.Textbox(label="Target Website URL",placeholder="Enter company website (e.g., techflowsolutions.com)",value="",elem_classes=["custom-input"])with gr.Row():max_results = gr.Slider(minimum=1,maximum=20,value=8,step=1,label="Maximum Results",elem_classes=["custom-input"])search_btn = gr.Button("Execute Search",variant="primary",size="lg",elem_classes=["primary-btn"])gr.HTML('<div class="section-header">Search Results</div>')with gr.Row():results_display = gr.Textbox(label="Contact Intelligence Report",lines=18,max_lines=35,show_copy_button=True,elem_classes=["results-container"])csv_output = gr.Textbox(label="Export Data (CSV Format)",lines=18,max_lines=35,show_copy_button=True,elem_classes=["results-container"])# CSV Upload Tabwith gr.TabItem("CSV Bulk Search"):with gr.Row():with gr.Column(scale=2):gr.HTML('<div class="section-header">CSV Upload</div>')csv_file = gr.File(label="Upload CSV File",file_types=[".csv"],elem_classes=["custom-input"])gr.HTML("""<div style="background: #f8fafc; padding: 15px; border-radius: 8px; border-left: 4px solid #1e40af; margin: 10px 0;"><strong>CSV Format Requirements:</strong><br>• Include a column named 'website', 'url', or 'domain'<br>• One website per row<br>• Example: techflowsolutions.com, greenleafconsult.com</div>""")with gr.Row():csv_max_results = gr.Slider(minimum=1,maximum=50,value=20,step=1,label="Maximum Results",elem_classes=["custom-input"])csv_search_btn = gr.Button("Process CSV",variant="primary",size="lg",elem_classes=["primary-btn"])gr.HTML('<div class="section-header">CSV Results</div>')with gr.Row():csv_results_display = gr.Textbox(label="CSV Processing Report",lines=18,max_lines=35,show_copy_button=True,elem_classes=["results-container"])csv_export_output = gr.Textbox(label="Export Data (CSV Format)",lines=18,max_lines=35,show_copy_button=True,elem_classes=["results-container"])# Sample websites sectionwith gr.Accordion("Sample Websites Database", open=False):gr.HTML('<div style="background: #f8fafc; padding: 15px; border-radius: 8px; border-left: 4px solid #1e40af;">')sample_websites = gr.Textbox(label="Available Websites in Database",value=get_all_available_websites(),lines=8,interactive=False,elem_classes=["custom-input"])gr.HTML('</div>')# Quick search buttonsgr.HTML('<div class="section-header">Quick Access Sample Websites</div>')with gr.Row():quick_btn1 = gr.Button("TechFlow Solutions", size="sm", elem_classes=["secondary-btn"])quick_btn2 = gr.Button("GreenLeaf Consulting", size="sm", elem_classes=["secondary-btn"])quick_btn3 = gr.Button("BlueSky Marketing", size="sm", elem_classes=["secondary-btn"])quick_btn4 = gr.Button("Quantum Dynamics", size="sm", elem_classes=["secondary-btn"])with gr.Row():quick_btn5 = gr.Button("Stellar Logistics", size="sm", elem_classes=["secondary-btn"])quick_btn6 = gr.Button("Nexus Financial", size="sm", elem_classes=["secondary-btn"])quick_btn7 = gr.Button("Horizon Health", size="sm", elem_classes=["secondary-btn"])quick_btn8 = gr.Button("Phoenix Manufacturing", size="sm", elem_classes=["secondary-btn"])# Event handlerssearch_btn.click(fn=search_website_contacts,inputs=[website_input, max_results],outputs=[results_display, csv_output])csv_search_btn.click(fn=search_csv_websites,inputs=[csv_file, csv_max_results],outputs=[csv_results_display, csv_export_output])# Quick search button handlersquick_btn1.click(lambda: "techflowsolutions.com", outputs=website_input)quick_btn2.click(lambda: "greenleafconsult.com", outputs=website_input)quick_btn3.click(lambda: "blueskymarketing.net", outputs=website_input)quick_btn4.click(lambda: "quantumdynamics.org", outputs=website_input)quick_btn5.click(lambda: "stellarlogistics.biz", outputs=website_input)quick_btn6.click(lambda: "nexusfinancial.pro", outputs=website_input)quick_btn7.click(lambda: "horizonhealth.care", outputs=website_input)quick_btn8.click(lambda: "phoenixmfg.com", outputs=website_input)# Examplesgr.Examples(examples=[["techflowsolutions.com", 5],["greenleafconsult.com", 3],["blueskymarketing.net", 4],["quantumdynamics.org", 6]],inputs=[website_input, max_results],label="Sample Searches")# Footergr.HTML("""<div style="text-align: center; padding: 30px 20px; background: linear-gradient(135deg, #64748b 0%, #475569 100%); color: white; border-radius: 15px; margin-top: 30px;"><h3 style="margin: 0 0 10px 0;">Contact Intelligence Platform</h3><p style="margin: 0; opacity: 0.9;">Professional-grade contact discovery and lead generation technology</p><p style="margin: 10px 0 0 0; font-size: 0.9em; opacity: 0.7;">Powered by advanced web intelligence algorithms</p></div>""")123456789206 unmodified lines21621721821922022122222322411 unmodified lines23623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342425 unmodified lines4504514524534544554564574584594604614624634644654664674684694704717 unmodified lines4794804814824834842 unmodified lines487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635import gradio as grimport pandas as pdimport numpy as npimport requestsimport reimport jsonimport iofrom urllib.parse import urlparse, urljoinimport time206 unmodified linesdef extract_domain(url):"""Extract domain from URL"""try:if not url or pd.isna(url):return ""url = str(url).strip()if not url.startswith(('http://', 'https://')):url = 'https://' + urlparsed = urlparse(url)11 unmodified linesif not target_domain:return []matching_contacts = []for contact in CONTACTS_DB:contact_domain = extract_domain(contact['website'])# Exact domain match or subdomain matchif target_domain == contact_domain or target_domain in contact_domain or contact_domain in target_domain:matching_contacts.append(contact)return matching_contactsdef simulate_website_scraping(url):"""Simulate scraping a website and finding contact information"""# Add some delay to simulate real scrapingtime.sleep(random.uniform(0.1, 0.3))# Find matching contacts from our databasecontacts = find_contacts_by_website(url)return contactsdef process_excel_file(excel_file):"""Process Excel file and populate contact information"""if excel_file is None:return "Please upload an Excel file", Nonetry:# Read the Excel filedf = pd.read_excel(excel_file.name)# Check if column H exists (index 7)if df.shape[1] < 8:return "Excel file must have at least 8 columns (up to column H for websites)", None# Ensure we have enough columns for all contact fieldsrequired_columns = 23 # Up to column W (index 22)current_columns = df.shape[1]# Add missing columns if neededif current_columns < required_columns:for i in range(current_columns, required_columns):df[f'Column_{chr(65+i)}'] = ''# Define column mappings (0-indexed)website_col = 7 # Column Hfirst_name_col = 8 # Column Ilast_name_col = 9 # Column Jjob_title_col = 10 # Column Kphone_col = 11 # Column Lemail_col = 12 # Column M# Second contact columnsfirst_name_2_col = 18 # Column Slast_name_2_col = 19 # Column Tjob_title_2_col = 20 # Column Uphone_2_col = 21 # Column Vemail_2_col = 22 # Column Wtotal_processed = 0contacts_found = 0# Process each rowfor index, row in df.iterrows():website_url = row.iloc[website_col] if pd.notna(row.iloc[website_col]) else ""if website_url:total_processed += 1print(f"Processing row {index + 1}: {website_url}")# Find contacts for this websitecontacts = simulate_website_scraping(website_url)if contacts:contacts_found += len(contacts)# Fill in first contactif len(contacts) >= 1:contact1 = contacts[0]df.iloc[index, first_name_col] = contact1['first_name']df.iloc[index, last_name_col] = contact1['last_name']df.iloc[index, job_title_col] = contact1['job_title']df.iloc[index, phone_col] = contact1['phone']df.iloc[index, email_col] = contact1['email']# Fill in second contact if availableif len(contacts) >= 2:contact2 = contacts[1]df.iloc[index, first_name_2_col] = contact2['first_name']df.iloc[index, last_name_2_col] = contact2['last_name']df.iloc[index, job_title_2_col] = contact2['job_title']df.iloc[index, phone_2_col] = contact2['phone']df.iloc[index, email_2_col] = contact2['email']# Create a summary reportreport = f"""EXCEL CONTACT PROCESSING REPORT{'='*50}File Processing Summary:- Total rows processed: {len(df)}- Rows with websites: {total_processed}- Total contacts found: {contacts_found}- Rows updated with contact info: {sum(1 for _, row in df.iterrows() if pd.notna(row.iloc[first_name_col]) and row.iloc[first_name_col] != '')}Column Mapping:- Column H: Website URLs (source)- Column I: Contact First Name- Column J: Contact Last Name- Column K: Job Title- Column L: Phone Number- Column M: Email Address- Column S: Second Contact First Name- Column T: Second Contact Last Name- Column U: Second Contact Job Title- Column V: Second Contact Phone- Column W: Second Contact EmailProcessing Details:"""# Add details for each processed rowfor index, row in df.iterrows():website_url = row.iloc[website_col] if pd.notna(row.iloc[website_col]) else ""if website_url:first_name = row.iloc[first_name_col] if pd.notna(row.iloc[first_name_col]) else ""if first_name:report += f"Row {index + 1}: {website_url} -> Found contact: {first_name}\n"else:report += f"Row {index + 1}: {website_url} -> No contacts found\n"# Save the updated Excel fileoutput_buffer = io.BytesIO()with pd.ExcelWriter(output_buffer, engine='openpyxl') as writer:df.to_excel(writer, index=False, sheet_name='Updated_Contacts')output_buffer.seek(0)return report, output_buffer.getvalue()except Exception as e:return f"Error processing Excel file: {str(e)}\n\nPlease ensure your Excel file:\n- Has websites in column H\n- Is a valid Excel format (.xlsx, .xls)\n- Is not password protected", Nonedef download_sample_excel():"""Create a sample Excel file for download"""try:# Create sample datasample_data = {'A': ['Company 1', 'Company 2', 'Company 3', 'Company 4', 'Company 5'],'B': ['Industry 1', 'Industry 2', 'Industry 3', 'Industry 4', 'Industry 5'],'C': ['City 1', 'City 2', 'City 3', 'City 4', 'City 5'],'D': ['State 1', 'State 2', 'State 3', 'State 4', 'State 5'],'E': ['Country 1', 'Country 2', 'Country 3', 'Country 4', 'Country 5'],'F': ['Notes 1', 'Notes 2', 'Notes 3', 'Notes 4', 'Notes 5'],'G': ['Status 1', 'Status 2', 'Status 3', 'Status 4', 'Status 5'],'H': ['techflowsolutions.com', 'greenleafconsult.com', 'blueskymarketing.net', 'quantumdynamics.org', 'stellarlogistics.biz'],'I': ['', '', '', '', ''], # Contact First Name'J': ['', '', '', '', ''], # Contact Last Name'K': ['', '', '', '', ''], # Job Title'L': ['', '', '', '', ''], # Phone'M': ['', '', '', '', ''], # Email'N': ['', '', '', '', ''],'O': ['', '', '', '', ''],'P': ['', '', '', '', ''],'Q': ['', '', '', '', ''],'R': ['', '', '', '', ''],'S': ['', '', '', '', ''], # Second Contact First Name'T': ['', '', '', '', ''], # Second Contact Last Name'U': ['', '', '', '', ''], # Second Contact Job Title'V': ['', '', '', '', ''], # Second Contact Phone'W': ['', '', '', '', ''], # Second Contact Email}df = pd.DataFrame(sample_data)# Save to bufferoutput_buffer = io.BytesIO()with pd.ExcelWriter(output_buffer, engine='openpyxl') as writer:df.to_excel(writer, index=False, sheet_name='Sample_Template')output_buffer.seek(0)return output_buffer.getvalue()except Exception as e:print(f"Error creating sample Excel: {e}")return None# Custom CSScustom_css = """25 unmodified linesopacity: 0.9;}.section-header {background: linear-gradient(135deg, #64748b 0%, #475569 100%);color: white;padding: 15px 20px;border-radius: 10px;margin: 20px 0 15px 0;font-weight: 600;}.info-box {background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);border: 2px solid #cbd5e1;border-radius: 15px;padding: 20px;margin: 10px 0;border-left: 5px solid #1e40af;}.primary-btn {7 unmodified linestransition: all 0.3s ease;}.results-container {background: white;border: 1px solid #e5e7eb;2 unmodified linesmargin: 15px 0;box-shadow: 0 2px 10px rgba(0,0,0,0.05);}"""# Create Gradio interfacewith gr.Blocks(css=custom_css, title="Excel Contact Discovery Platform", theme=gr.themes.Base()) as app:gr.HTML("""<div class="main-header"><h1>Excel Contact Discovery Platform</h1><p>Automated Contact Discovery for Excel Spreadsheets</p><p style="font-size: 0.95em; opacity: 0.8;">Upload your Excel file and automatically populate contact information</p></div>""")with gr.Tab("Excel Processing"):gr.HTML('<div class="section-header">Excel File Upload</div>')with gr.Row():with gr.Column(scale=2):excel_file = gr.File(label="Upload Excel File (.xlsx, .xls)",file_types=[".xlsx", ".xls"],elem_classes=["custom-input"])process_btn = gr.Button("Process Excel File",variant="primary",size="lg",elem_classes=["primary-btn"])gr.HTML("""<div class="info-box"><h3>Excel File Requirements:</h3><ul><li><strong>Column H:</strong> Must contain website URLs (e.g., techflowsolutions.com)</li><li><strong>Contact Info will be populated in:</strong></li><ul><li>Column I: Contact First Name</li><li>Column J: Contact Last Name</li><li>Column K: Job Title</li><li>Column L: Phone Number</li><li>Column M: Email Address</li></ul><li><strong>Second Contact (if found) will be populated in:</strong></li><ul><li>Column S: Second Contact First Name</li><li>Column T: Second Contact Last Name</li><li>Column U: Second Contact Job Title</li><li>Column V: Second Contact Phone</li><li>Column W: Second Contact Email</li></ul></ul></div>""")gr.HTML('<div class="section-header">Processing Results</div>')processing_report = gr.Textbox(label="Processing Report",lines=20,max_lines=30,show_copy_button=True,elem_classes=["results-container"])download_file = gr.File(label="Download Updated Excel File",elem_classes=["results-container"])with gr.Tab("Sample Template"):gr.HTML('<div class="section-header">Download Sample Template</div>')gr.HTML("""<div class="info-box"><h3>Sample Excel Template</h3><p>Download this sample template to see the expected format. The template includes:</p><ul><li>Sample data in columns A-G</li><li>Website URLs in column H</li><li>Empty contact columns (I-M) ready to be populated</li><li>Empty second contact columns (S-W) ready to be populated</li></ul><p>Replace the sample websites in column H with your actual website URLs.</p></div>""")sample_download_btn = gr.Button("Download Sample Template",variant="secondary",size="lg")sample_file = gr.File(label="Sample Template Download",elem_classes=["results-container"])with gr.Tab("Available Sample Websites"):gr.HTML('<div class="section-header">Test Websites Database</div>')sample_websites_text = """Available websites in our test database:techflowsolutions.com - TechFlow Solutionsgreenleafconsult.com - GreenLeaf Consultingblueskymarketing.net - BlueSky Marketingquantumdynamics.org - Quantum Dynamics Corpstellarlogistics.biz - Stellar Logisticsnexusfinancial.pro - Nexus Financialhorizonhealth.care - Horizon Health Systemsphoenixmfg.com - Phoenix Manufacturingalpineeducation.edu - Alpine Education Groupcrimsoncreative.studio - Crimson Creative StudioYou can use these websites in column H of your Excel file to test the system."""gr.Textbox(value=sample_websites_text,label="Sample Websites for Testing",lines=15,interactive=False,elem_classes=["results-container"])# Event handlersprocess_btn.click(fn=process_excel_file,inputs=[excel_file],outputs=[processing_report, download_file])sample_download_btn.click(fn=download_sample_excel,inputs=[],outputs=[sample_file])# Footergr.HTML("""<div style="text-align: center; padding: 30px 20px; background: linear-gradient(135deg, #64748b 0%, #475569 100%); color: white; border-radius: 15px; margin-top: 30px;"><h3 style="margin: 0 0 10px 0;">Excel Contact Discovery Platform</h3><p style="margin: 0; opacity: 0.9;">Automated contact discovery and Excel integration</p><p style="margin: 10px 0 0 0; font-size: 0.9em; opacity: 0.7;">Upload Excel → Find Contacts → Download Updated File</p></div>""")
app.py+274-363