# # Gradio interface # from functionality.funct import convert_json_to_files # import gradio as gr # # iface = gr.Interface( # # fn=convert_json_to_files, # # inputs="text", # # outputs=[ # # gr.Dataframe(label="CSV Preview"), # Display the DataFrame # # gr.File(label="Download Excel File") # Downloadable Excel file # # ], # # title="JSON to CSV and XLSX Converter", # # description="Upload your JSON data, preview the CSV, and download the converted CSV and XLSX files." # # ) # iface = gr.Interface( # fn=convert_json_to_files, # inputs=gr.Textbox(label="Input JSON Data", placeholder='Enter JSON data here...', lines=10), # outputs=[ # gr.Dataframe(label="CSV Preview"), # Display the DataFrame # gr.File(label="Download Excel File") # Downloadable Excel file # ], # title="Leads Fetcher", # description="Upload your JSON data, preview the CSV, and download the converted CSV and XLSX files." # ) # iface.launch(share=True) # Gradio interface from functionality.funct import convert_json_to_files import gradio as gr # Function to validate if inputs are filled def is_input_valid(api_key, json_data): return bool(api_key.strip()) and bool(json_data.strip()) # Main function to process the inputs def process_inputs(api_key, json_data): # Replace with actual processing logic if needed return convert_json_to_files(api_key, json_data) # Interface setup with gr.Blocks() as iface: gr.Markdown( """ # Leads Fetcher This tool allows you to input JSON data and fetch the corresponding leads. Make sure to enter a valid API Key and your JSON data to get the CSV preview and download the converted Excel file. **[NOTE]**: If you are using free plan of Apollo it will allow only 5 pages of fetching per request, total 125 Leads per request. """ ) with gr.Row(): with gr.Column(): api_key_input = gr.Textbox( label="API Key for Apollo", placeholder="Enter your API key here...", lines=1, ) json_input = gr.Textbox( label="Input JSON Data", placeholder="Enter JSON data here...", lines=10 ) submit_btn = gr.Button("Submit") with gr.Column(): csv_output = gr.Dataframe(label="CSV Preview") file_output = gr.File(label="Download Excel File") # Control button state def update_submit_state(api_key, json_data): return gr.update(interactive=is_input_valid(api_key, json_data)) api_key_input.change( fn=update_submit_state, inputs=[api_key_input, json_input], outputs=submit_btn ) json_input.change( fn=update_submit_state, inputs=[api_key_input, json_input], outputs=submit_btn ) submit_btn.click( fn=process_inputs, inputs=[api_key_input, json_input], outputs=[csv_output, file_output], ) examples = gr.Examples( examples=[ [ "OykhjTWxqLFmU4fXgwqK5A", '{"page":1,"sort_by_field":"[none]","sort_ascending":false,"contact_email_status_v2":["likely_to_engage","verified"],"person_department_or_subdepartments":["master_sales"],"person_locations":["United States"],"person_seniorities":["director"],"included_organization_keyword_fields":["tags","name","social_media_description","seo_description"],"q_organization_keyword_tags":["app development"],"organization_num_employees_ranges":["101,200"],"display_mode":"explorer_mode","per_page":25,"open_factor_names":[],"num_fetch_result":1,"context":"people-index-page","show_suggestions":false,"include_account_engagement_stats":false,"include_contact_engagement_stats":false,"finder_version":2,"ui_finder_random_seed":"6gfkmmnjsqn","typed_custom_fields":[],"cacheKey":1735714146736}', ] ], inputs=[api_key_input, json_input], ) gr.Markdown("
") gr.Markdown( """ ## How to get JSON input ## 1. Go to the Apollo filtered link (for example): [Apollo Filtered Link](https://app.apollo.io/#/people?page=1&contactEmailStatusV2[]=likely_to_engage&contactEmailStatusV2[]=verified&prospectedByCurrentTeam[]=no&sortByField=%5Bnone%5D&sortAscending=false&includedOrganizationKeywordFields[]=tags&includedOrganizationKeywordFields[]=name&organizationIndustryTagIds[]=5567cd4773696439b10b0000&personLocations[]=United%20States&organizationNumEmployeesRanges[]=21%2C50&organizationNumEmployeesRanges[]=51%2C100&organizationNumEmployeesRanges[]=101%2C200&organizationNumEmployeesRanges[]=201%2C500&excludedOrganizationKeywordFields[]=tags&excludedOrganizationKeywordFields[]=name&excludedOrganizationKeywordFields[]=social_media_description&excludedOrganizationKeywordFields[]=seo_description&personDepartmentOrSubdepartments[]=master_human_resources&personSeniorities[]=entry&personSeniorities[]=senior&personSeniorities[]=manager&personSeniorities[]=director&personSeniorities[]=head&personSeniorities[]=vp&personSeniorities[]=c_suite&personSeniorities[]=partner) 2. Open **Inspect Element** in your browser and navigate to the **Network** tab. 3. Click on the first **"search"** entry in the **Name** column. 4. Click on **"View Parsed"** and copy the entire payload. --- ![Leads Fetcher Demo](https://i.ibb.co/2qwk2vd/ezgif-2-93235bbbb8.gif) """ ) iface.launch(share=True)