import gradio as gr import base64 #import execjs # Define the Mermaid code for the flowchart mermaid_code = """graph TD; A[Start] --> B[Decision]; B -- Yes --> C[Option 1]; B -- No --> D[Option 2]; C --> E[End]; D --> E; E[End] --> F[End]; """ #def call_chart(mermaidCode): def mm(graph=mermaid_code): code_out="" for ea in mermaid_code.split("\n"): code=ea.strip().strip("\n") code_out+=code out_html=f'''
''' return out_html """ graph LR; A--> B & C & D; B--> A & E; C--> A & E; D--> A & E; E--> B & C & D; """ with gr.Blocks() as app: inp_text=gr.Textbox(value=mermaid_code) btn=gr.Button() out_html=gr.HTML("""""") btn.click(mm,inp_text,out_html) app.load(mm,inp_text,out_html) app.launch()