import requests import gradio as gr import json def get_api(inp,call,val,tot): if not tot: r = requests.get(f'{inp}?{call}={val}') return (r.text) else: out_box=[] data="" for i in range(int(val)): try: r = requests.get(f'{inp}?{call}={i}') new_data=r.text new_dict = dict(new_data) #data = dict(data) + dict(new_data) #out={"id":r.text['id']} #print (out) out_box.append(new_dict) except Exception as e: print (f"{i} - {e}") pass yield (out_box) with gr.Blocks() as app: with gr.Group(): with gr.Row(): with gr.Column(scale=3): api_url=gr.Textbox(label="API URL") with gr.Column(scale=2): with gr.Row(): api_call=gr.Textbox(label="API CALL") api_val=gr.Textbox(label="VALUE") with gr.Column(scale=1): val_tot=gr.Checkbox(label="Count", value=False) btn=gr.Button() outp=gr.JSON() btn.click(get_api,[api_url,api_call,api_val,val_tot],outp) app.launch()