Omnibus commited on
Commit
0406768
1 Parent(s): 12edcd9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -9
app.py CHANGED
@@ -540,9 +540,9 @@ def clear_fn():
540
  return "",[(None,None)]
541
 
542
  def create_image(url):
543
- source = requests.get(url)
544
  #source = urllib.request.urlopen(url).read()
545
- soup = bs4.BeautifulSoup(source.content,'lxml')
546
 
547
  #rawp=(f'RAW TEXT RETURNED: {soup.text}')
548
  #cnt=0
@@ -550,15 +550,26 @@ def create_image(url):
550
  #out.append(rawp)
551
  #out.append("HTML fragments: ")
552
  #q=("a","p","span","content","article")
553
- out=[]
554
- for b in soup.find_all("div"):
555
- for p in b.find_all("pre, {'class': 'mermaid'}"):
556
- out.append(p.find('svg'))
557
- print(out)
558
  #out.append(p.string)
559
  with open("tmp.svg","w") as svg:
560
- svg.write(out[0])
561
  return "tmp.svg"
 
 
 
 
 
 
 
 
 
 
 
562
  def zoom_update(inp):
563
  this.clear()
564
  this.append(str(inp))
@@ -603,7 +614,13 @@ with gr.Blocks() as app:
603
  json_out=gr.JSON()
604
  #text=gr.JSON()
605
 
606
- create_im.click(create_image,url_box,svg_img)
 
 
 
 
 
 
607
  #zoom_btn.change(zoom_update,zoom_btn,None)
608
  upd_button.click(mm,[e_box,zoom_btn],[m_box,url_box])
609
  #inp_query.change(search_models,inp_query,models_dd)
 
540
  return "",[(None,None)]
541
 
542
  def create_image(url):
543
+ #source = requests.get(url)
544
  #source = urllib.request.urlopen(url).read()
545
+ #soup = bs4.BeautifulSoup(source.content,'lxml')
546
 
547
  #rawp=(f'RAW TEXT RETURNED: {soup.text}')
548
  #cnt=0
 
550
  #out.append(rawp)
551
  #out.append("HTML fragments: ")
552
  #q=("a","p","span","content","article")
553
+ #out=[]
554
+ #for b in soup.find_all("div"):
555
+ # for p in b.find_all("pre, {'class': 'mermaid'}"):
556
+ # out.append(p.find('svg'))
557
+ print(url)
558
  #out.append(p.string)
559
  with open("tmp.svg","w") as svg:
560
+ svg.write(url)
561
  return "tmp.svg"
562
+
563
+ score_js="""
564
+ function(text_input) {
565
+ console.log(text_input);
566
+ const iframe = document.getElementById("frame").contentWindow.document.getElementById('chart').innerHTML;
567
+ console.log(iframe);
568
+ return [iframe];
569
+ }
570
+ """
571
+
572
+
573
  def zoom_update(inp):
574
  this.clear()
575
  this.append(str(inp))
 
614
  json_out=gr.JSON()
615
  #text=gr.JSON()
616
 
617
+ #get_score.click(return_score,score,[score],_js=score_js)
618
+
619
+ score=gr.Textbox()
620
+ def return_score(text):
621
+ print(text)
622
+ return text
623
+ create_im.click(return_score,score,[score],_js=score_js).then(create_image,score,svg_img)
624
  #zoom_btn.change(zoom_update,zoom_btn,None)
625
  upd_button.click(mm,[e_box,zoom_btn],[m_box,url_box])
626
  #inp_query.change(search_models,inp_query,models_dd)