Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,25 +8,26 @@ html = """
|
|
8 |
PAGE_LINK
|
9 |
</div>
|
10 |
"""
|
11 |
-
|
|
|
|
|
|
|
|
|
12 |
|
13 |
def make_tree(url1="",url2="",url3="",url4=""):
|
14 |
link_box=[]
|
15 |
html_out=""
|
16 |
get_url=f'{main_directory}{url1}{url2}{url3}{url4}'
|
17 |
feed1 = requests.get(get_url)
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
link_box.append(fin)
|
28 |
-
#html_out=html_out+html.replace("PAGE_LINK",fin)
|
29 |
-
return None, gr.update(choices=[l for l in link_box],interactive=True)
|
30 |
|
31 |
def run():
|
32 |
_,out=make_tree()
|
@@ -38,10 +39,12 @@ with gr.Blocks() as app:
|
|
38 |
drop2=gr.Dropdown()
|
39 |
drop3=gr.Dropdown()
|
40 |
drop4=gr.Dropdown()
|
|
|
41 |
links=gr.JSON()
|
42 |
html_=gr.HTML()
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
46 |
app.load(run,None,[drop1])
|
47 |
app.launch()
|
|
|
8 |
PAGE_LINK
|
9 |
</div>
|
10 |
"""
|
11 |
+
def load_json(url1="",url2="",url3="",url4=""):
|
12 |
+
get_url=f'{main_directory}{url1}{url2}{url3}{url4}'
|
13 |
+
feed1 = requests.get(get_url)
|
14 |
+
if get_url.endswith(".json"):
|
15 |
+
return feed1.text
|
16 |
|
17 |
def make_tree(url1="",url2="",url3="",url4=""):
|
18 |
link_box=[]
|
19 |
html_out=""
|
20 |
get_url=f'{main_directory}{url1}{url2}{url3}{url4}'
|
21 |
feed1 = requests.get(get_url)
|
22 |
+
spl = feed1.text.split("href=")
|
23 |
+
for line in spl:
|
24 |
+
spl2 = line.split(">")[0]
|
25 |
+
print(spl2)
|
26 |
+
if spl2.endswith('/"') or spl2.endswith('.json"'):
|
27 |
+
fin=line.split(">")[0].strip('""')
|
28 |
+
link_box.append(fin)
|
29 |
+
#html_out=html_out+html.replace("PAGE_LINK",fin)
|
30 |
+
return gr.update(choices=[l for l in link_box],interactive=True)
|
|
|
|
|
|
|
31 |
|
32 |
def run():
|
33 |
_,out=make_tree()
|
|
|
39 |
drop2=gr.Dropdown()
|
40 |
drop3=gr.Dropdown()
|
41 |
drop4=gr.Dropdown()
|
42 |
+
load_btn=gr.Button("Load JSON")
|
43 |
links=gr.JSON()
|
44 |
html_=gr.HTML()
|
45 |
+
load_btn.click(load_json,[drop1,drop2,drop3,drop4],links)
|
46 |
+
drop1.change(make_tree,drop1,[drop2])
|
47 |
+
drop2.change(make_tree,[drop1,drop2],[drop3])
|
48 |
+
drop3.change(make_tree,[drop1,drop2,drop3],[drop4])
|
49 |
app.load(run,None,[drop1])
|
50 |
app.launch()
|