File size: 1,233 Bytes
4543167
 
8453b30
4543167
aeb0a07
 
 
 
 
8453b30
b63131f
aeb0a07
 
 
bab0a66
b63131f
 
c9cabf7
 
b63131f
aeb0a07
29146d2
aeb0a07
b63131f
4543167
c595dd2
 
 
 
 
 
 
 
 
 
 
fb8bd23
aeb0a07
4543167
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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()