1littlecoder commited on
Commit
90efa7a
1 Parent(s): e7a385f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
  import base64
3
 
4
- # HTML template for rendering Mermaid diagrams
5
  html_template = """
6
  <!DOCTYPE html>
7
  <html>
@@ -35,14 +34,19 @@ def render_mermaid(mermaid_code):
35
 
36
  return html_content, png_url
37
 
38
- # Create a Gradio interface
39
- iface = gr.Interface(
40
- fn=render_mermaid,
41
- inputs="text",
42
- outputs=["html", "image"],
43
- title="Mermaid Diagram Renderer",
44
- description="Input your Mermaid diagram code to render it and get a PNG image."
45
- )
 
 
 
 
 
46
 
47
  # Launch the app
48
- iface.launch()
 
1
  import gradio as gr
2
  import base64
3
 
 
4
  html_template = """
5
  <!DOCTYPE html>
6
  <html>
 
34
 
35
  return html_content, png_url
36
 
37
+ with gr.Blocks(theme=gr.themes.Citrus()) as mrender:
38
+ gr.Markdown("# Mermaid Diagram Renderer")
39
+ gr.Markdown("Input your Mermaid diagram code to render it and get a PNG image.")
40
+
41
+ with gr.Row():
42
+ with gr.Column():
43
+ mermaid_input = gr.Textbox(label="Mermaid Code", placeholder="Enter your Mermaid diagram code here...")
44
+ submit_btn = gr.Button("Render")
45
+ with gr.Column():
46
+ html_output = gr.HTML()
47
+ image_output = gr.Image()
48
+
49
+ submit_btn.click(fn=render_mermaid, inputs=mermaid_input, outputs=[html_output, image_output])
50
 
51
  # Launch the app
52
+ mrender.launch()