Hi,
Iām trying to achieve a function that runs every 10 seconds with every
I highlighted what row of the code that I want to use every
this is my GUI:
##Gradio GUI###
with gr.Blocks(title = āIPBlockerā) as switches_ver:
gr.Markdown(āWelcome to IPBlockerā)
with gr.Row():
fg_names = [āDCDR Statusā,āTLV Statusā,āHFA Statusā, āKRML Statusā]
for name in fg_names:
gr.Textbox(value = threat_feed_check(name), label = name, interactive=False, every=10)
with gr.Tab(label = āIPBlockerā):
with gr.Row():
with gr.Column():
ips_to_block = gr.Textbox(label = āIPsā, lines = 10, placeholder=(āPlease fill Ips to blockā))
block_btn = gr.Button(āBlockā)
with gr.Row():
ip_look_up_btn = gr.Button('Look for IP or URL: ')
look_up = gr.Textbox(show_label=False)
with gr.Row():
ip_removal_btn = gr.Button(āRemove IP:ā)
remove = gr.Textbox(show_label=False)with gr.Column(): output_textbox = gr.Textbox(label = "Results", lines=10) with gr.Row(): current_commit_stats = gr.Textbox(label = 'Current IP\s or URLs added to block:') forti_ips_stats = gr.Textbox(label = 'Total blocked IP\s on Fortigate: ') forti_urls_stats = gr.Textbox(label = 'Total URLs blocked on Fortigate') forti_total_stats = gr.Textbox(label = 'Total blocked IP\s and URLs on Fortigate') block_btn.click(fn=block_ip, inputs = ips_to_block, outputs = [output_textbox, current_commit_stats, forti_ips_stats, forti_urls_stats, forti_total_stats]) ip_look_up_btn.click(fn=ip_look_up, inputs = look_up, outputs = look_up) ip_removal_btn.click(fn=ip_removal, inputs = remove, outputs = remove)
switches_ver.queue().launch()
My function:
def threat_feed_check(threat_feed):
if threat_feed == 'DCDR Status':
response = requests.get('https://192.168.1.1/api/v2/monitor/system/external-resource/entry-list?mkey=Domain_Blocker&vdom=root', headers=headers, verify=False)
print('Trying')
return response.json()['results']
if threat_feed == 'TLV Status':
response = requests.get('https://192.168.1.2/api/v2/monitor/system/external-resource/entry-list?mkey=Domain_Blocker&vdom=root', headers=headers, verify=False)
return response.json()['results']
if threat_feed == 'HFA Status':
response = requests.get('https://192.168.1.3/api/v2/monitor/system/external-resource/entry-list?mkey=Domain_Blocker&vdom=root', headers=headers, verify=False)
return response.json()['results']
if threat_feed == 'KRML Status':
response = requests.get('https://192.168.1.4/api/v2/monitor/system/external-resource/entry-list?mkey=Domain_Blocker&vdom=root', headers=headers, verify=False)
return response.json()['results']
Any Idea why It doesnāt work?
Thank you!