Omnibus commited on
Commit
73c565e
·
verified ·
1 Parent(s): c875e8e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -6
app.py CHANGED
@@ -21,15 +21,27 @@ js_c=("""
21
  }
22
  """)
23
 
24
- def call_chart(mermaidCode):
25
- # Render the flowchart
26
- #context.call("renderMermaid", mermaid_code)
27
- # Print the Mermaid code for reference
28
- print(mermaid_code)
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  with gr.Blocks() as app:
31
  inp_text=gr.Textbox(value=mermaid_code)
32
 
33
  out_html=gr.HTML("""<div id='diagram'>Text</div>""")
34
- app.load(call_chart,inp_text,None,js=js_c)
35
  app.launch()
 
21
  }
22
  """)
23
 
24
+ #def call_chart(mermaidCode):
25
+ def mm(graph):
26
+ graphbytes = graph.encode("utf8")
27
+ base64_bytes = base64.b64encode(graphbytes)
28
+ base64_string = base64_bytes.decode("ascii")
29
+ #display(Image(url="https://mermaid.ink/img/" + base64_string))
30
+ out_im=f"""<img src="https://mermaid.ink/img/" + {base64_string}"""
31
+ return gr.update(out_im0
32
+
33
+ """
34
+ graph LR;
35
+ A--> B & C & D;
36
+ B--> A & E;
37
+ C--> A & E;
38
+ D--> A & E;
39
+ E--> B & C & D;
40
+ """
41
 
42
  with gr.Blocks() as app:
43
  inp_text=gr.Textbox(value=mermaid_code)
44
 
45
  out_html=gr.HTML("""<div id='diagram'>Text</div>""")
46
+ app.load(mm,inp_text,out_html)
47
  app.launch()