File size: 1,519 Bytes
4543167
 
8453b30
6d1811e
aeb0a07
 
 
b1b9b1f
0eaaceb
41db73c
 
aeb0a07
8453b30
b63131f
aeb0a07
35e81c6
aeb0a07
41db73c
bab0a66
e969e75
a7e5819
41db73c
 
 
aeb0a07
29146d2
aeb0a07
b63131f
4543167
c595dd2
 
 
 
 
 
 
 
 
 
55c811c
 
 
fb8bd23
55c811c
 
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
40
41
42
43
44
45
46
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}')
        new_data=r.text
        print (new_data)
        #new_dict = json.loads(new_data)        
        return (new_data)
    else:
        out_box=[]
        data=""
        for i in range(int(val)):
            
            try:
                r = requests.get(f'{inp}?{call}={int(val)-i}')
                new_data=r.text
                new_dict = json.loads(new_data)
                #print (new_dict)
                if "2024" in new_dict["data"]["member_since"]:
                    #print(new_dict)
                    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)
        with gr.Row():
            btn=gr.Button("Search")
            stop_btn=gr.Button("Stop")
    outp=gr.JSON()
    go_btn = btn.click(get_api,[api_url,api_call,api_val,val_tot],outp)
    stop_btn.click(None,None,None,cancels=[go_btn])
app.launch()