Omnibus commited on
Commit
0d0db28
·
verified ·
1 Parent(s): b52ef6a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -14
app.py CHANGED
@@ -13,19 +13,23 @@ PAGE_LINK
13
  def make_tree(url1="",url2="",url3="",url4=""):
14
  link_box=[]
15
  html_out=""
16
- feed1 = requests.get(f'{main_directory}{url1}{url2}{url3}{url4}')
17
- spl = feed1.text.split("href=")
18
- for line in spl:
19
- spl2 = line.split(">")[0]
20
- print(spl2)
21
- if spl2.endswith('/"') or spl2.endswith('.json"'):
22
- fin=line.split(">")[0].strip('""')
23
- link_box.append(fin)
24
- #html_out=html_out+html.replace("PAGE_LINK",fin)
25
- return gr.update(choices=[l for l in link_box],interactive=True)
 
 
 
 
26
 
27
  def run():
28
- out=make_tree()
29
  return out
30
 
31
  with gr.Blocks() as app:
@@ -36,8 +40,8 @@ with gr.Blocks() as app:
36
  drop4=gr.Dropdown()
37
  links=gr.JSON()
38
  html_=gr.HTML()
39
- drop1.change(make_tree,drop1,drop2)
40
- drop2.change(make_tree,[drop1,drop2],drop3)
41
- drop3.change(make_tree,[drop1,drop2,drop3],drop4)
42
  app.load(run,None,[drop1])
43
  app.launch()
 
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
+ if get_url.endswith(".json"):
19
+ return feed1.text, None
20
+ else:
21
+ spl = feed1.text.split("href=")
22
+ for line in spl:
23
+ spl2 = line.split(">")[0]
24
+ print(spl2)
25
+ if spl2.endswith('/"') or spl2.endswith('.json"'):
26
+ fin=line.split(">")[0].strip('""')
27
+ link_box.append(fin)
28
+ #html_out=html_out+html.replace("PAGE_LINK",fin)
29
+ return out_json, gr.update(choices=[l for l in link_box],interactive=True)
30
 
31
  def run():
32
+ _,out=make_tree()
33
  return out
34
 
35
  with gr.Blocks() as app:
 
40
  drop4=gr.Dropdown()
41
  links=gr.JSON()
42
  html_=gr.HTML()
43
+ drop1.change(make_tree,drop1,[links,drop2])
44
+ drop2.change(make_tree,[drop1,drop2],[links,drop3])
45
+ drop3.change(make_tree,[drop1,drop2,drop3],[links,drop4])
46
  app.load(run,None,[drop1])
47
  app.launch()