Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,32 @@
|
|
| 1 |
import requests
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
def get_api(inp):
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
with gr.Blocks() as app:
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
btn=gr.Button()
|
| 11 |
outp=gr.JSON()
|
| 12 |
-
btn.click(get_api,
|
| 13 |
app.launch()
|
|
|
|
| 1 |
import requests
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
def get_api(inp,call,val,tot):
|
| 5 |
+
if not tot:
|
| 6 |
+
r = requests.get(f'{inp}?{call}={val}')
|
| 7 |
+
return (r.text)
|
| 8 |
+
else:
|
| 9 |
+
out_box=[]
|
| 10 |
+
for i in range(int(val)):
|
| 11 |
+
try:
|
| 12 |
+
r = requests.get(f'{inp}?{call}={i}')
|
| 13 |
+
out_box.append(r.text)
|
| 14 |
+
except Exception as e:
|
| 15 |
+
print (i+" - "+e)
|
| 16 |
+
pass
|
| 17 |
+
return (out_box)
|
| 18 |
with gr.Blocks() as app:
|
| 19 |
+
|
| 20 |
+
with gr.Row():
|
| 21 |
+
with gr.Column(scale=3):
|
| 22 |
+
api_url=gr.Textbox(label="API URL")
|
| 23 |
+
with gr.Column(scale=2):
|
| 24 |
+
with gr.Row():
|
| 25 |
+
api_call=gr.Textbox(label="API CALL")
|
| 26 |
+
api_val=gr.Textbox(label="VALUE")
|
| 27 |
+
with gr.Column(scale=1):
|
| 28 |
+
val_tot=gr.Checkbox(label="Count", value=False)
|
| 29 |
btn=gr.Button()
|
| 30 |
outp=gr.JSON()
|
| 31 |
+
btn.click(get_api,[api_url,api_call,api_val,val_tot],outp)
|
| 32 |
app.launch()
|