import requests import gradio as gr import json #132942 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 = json.loads(new_data) if '2024' in new_dict: #data = dict(data) + dict(new_data) #out={"id":r.text['id']} #print (out) print(new_dict) out_box.append({'id':new_dict['id']}) 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()