Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import requests
|
2 |
from datasets import load_dataset
|
3 |
|
@@ -10,14 +11,23 @@ def query1():
|
|
10 |
response = requests.get(API_URL1)
|
11 |
#response = requests.get(API_URL1, headers=headers)
|
12 |
return response.json()
|
13 |
-
data = query1()
|
14 |
-
print (data)
|
15 |
|
16 |
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
response = requests.get(API_URL2)
|
20 |
return response.json()
|
21 |
-
data = query2()
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
import requests
|
3 |
from datasets import load_dataset
|
4 |
|
|
|
11 |
response = requests.get(API_URL1)
|
12 |
#response = requests.get(API_URL1, headers=headers)
|
13 |
return response.json()
|
14 |
+
data = query1()
|
15 |
+
print (data)
|
16 |
|
17 |
|
18 |
+
def query2(fetch_url):
|
19 |
+
if fetch_url=="":
|
20 |
+
fetch_url = "nlphuji/flickr30k"
|
21 |
+
|
22 |
+
API_URL2 = f"https://datasets-server.huggingface.co/rows?dataset={fetch_url}&config=TEST&split=test&offset=150&length=10"
|
23 |
+
|
24 |
response = requests.get(API_URL2)
|
25 |
return response.json()
|
|
|
26 |
|
27 |
+
|
28 |
+
with gr.Blocks as app:
|
29 |
+
data_set_url=gr.Textbox():
|
30 |
+
fetch_btn=gr.Button():
|
31 |
+
out_json = gr.JSON():
|
32 |
+
fetch_btn.click(query2,data_set_url,out_json)
|
33 |
+
app.launch()
|