# import json import time import gradio as gr import threading import requests url_list = [ "https://spiny-upbeat-lingonberry.glitch.me/", "https://wooded-near-science.glitch.me/", "https://airzy.glitch.me/api", "https://bubble-magnificent-bicycle.glitch.me/api/wake" ] payload = { "data": "goodmorning_avy" # Replace with the actual data you want to send } headers = { "Content-Type": "application/json" } result_counter = 0 # Initialize counter result_counter2 = 0 # Initialize counter url_i = 0 result_string = "" def greet(input_text): return f"activity({result_counter} / {result_counter2}) input: " + input_text + "\n" + result_string result_string += "\n[Prepare]" iface = gr.Interface(fn=greet, inputs="text", outputs="text") def run_interface(): iface.launch() # Start Gradio interface in a separate thread gr_interface_thread = threading.Thread(target=run_interface) gr_interface_thread.start() result_string += "\n[Ready]\n" while True: url_i = 0 result_counter2 += 1 for url in url_list: url_i += 1 try: requests.post(url, json=payload, headers=headers) result_counter += 1/len(url_list) except urllib.error.URLError as e: print(f"Error ({url_i}):", str(e)) result_string += f"\n({result_counter})[ERROR] {str(e)}\n in ({url})\n\n" time.sleep(120)