raannakasturi commited on
Commit
0536e96
·
verified ·
1 Parent(s): 95edfe7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -43
app.py CHANGED
@@ -1,43 +1,43 @@
1
- import sys
2
- from generate_mindmap import generate_mindmap
3
- import gradio as gr
4
- import subprocess
5
-
6
- def generate(mindmap_markdown):
7
- mindmap_svg, mindmap_pdf = generate_mindmap(mindmap_markdown)
8
- with open(mindmap_svg, 'wb') as f:
9
- svg_mindmap = f.read()
10
- with open(mindmap_pdf, 'wb') as f:
11
- pdf_mindmap = f.read
12
- return svg_mindmap, pdf_mindmap
13
-
14
- theme = gr.themes.Soft(
15
- primary_hue="purple",
16
- secondary_hue="cyan",
17
- neutral_hue="slate",
18
- font=[gr.themes.GoogleFont('Syne'), gr.themes.GoogleFont('Poppins')],
19
- )
20
-
21
- with gr.Blocks(theme=theme, title="Binary Biology") as app:
22
- with gr.Row():
23
- with gr.Column():
24
- mindmap_markdown = gr.Textbox(label="Mindmap Markdown", placeholder="Enter the markdown for the mindmap", lines=10)
25
- generate_mindmap = gr.Button(value="Generate Mindmap")
26
- with gr.Column():
27
- svg_mindmap = gr.TextArea(label="SVG Mindmap", placeholder="The SVG representation of the mindmap", lines=10, readonly=True)
28
- pdf_mindmap = gr.TextArea(label="PDF Mindmap", placeholder="The PDF representation of the mindmap", lines=10, readonly=True)
29
- generate_mindmap.click(generate, inputs=[mindmap_markdown], outputs=[svg_mindmap, pdf_mindmap])
30
-
31
- if __name__ == "__main__":
32
- try:
33
- subprocess.run(['apt', 'install', '-y', 'graphviz'])
34
- print("Graphviz installed successfully")
35
- except Exception:
36
- try:
37
- subprocess.run(['sudo', 'apt', 'install', '-y', 'graphviz'])
38
- print("Graphviz installed successfully using sudo")
39
- except:
40
- print("Graphviz installation failed")
41
- sys.exit(1)
42
- print("Graphviz loaded successfully")
43
- app.queue(default_concurrency_limit=25).launch(show_error=True)
 
1
+ import sys
2
+ from generate_mindmap import generate_mindmap
3
+ import gradio as gr
4
+ import subprocess
5
+
6
+ def generate(mindmap_markdown):
7
+ mindmap_svg, mindmap_pdf = generate_mindmap(mindmap_markdown)
8
+ with open(mindmap_svg, 'wb') as f:
9
+ svg_mindmap = f.read()
10
+ with open(mindmap_pdf, 'wb') as f:
11
+ pdf_mindmap = f.read
12
+ return str(svg_mindmap), str(pdf_mindmap)
13
+
14
+ theme = gr.themes.Soft(
15
+ primary_hue="purple",
16
+ secondary_hue="cyan",
17
+ neutral_hue="slate",
18
+ font=[gr.themes.GoogleFont('Syne'), gr.themes.GoogleFont('Poppins')],
19
+ )
20
+
21
+ with gr.Blocks(theme=theme, title="Binary Biology") as app:
22
+ with gr.Row():
23
+ with gr.Column():
24
+ mindmap_markdown = gr.Textbox(label="Mindmap Markdown", placeholder="Enter the markdown for the mindmap", lines=10)
25
+ generate_mindmap = gr.Button(value="Generate Mindmap")
26
+ with gr.Column():
27
+ svg_mindmap = gr.TextArea(label="SVG Mindmap", placeholder="The SVG representation of the mindmap", lines=10)
28
+ pdf_mindmap = gr.TextArea(label="PDF Mindmap", placeholder="The PDF representation of the mindmap", lines=10)
29
+ generate_mindmap.click(generate, inputs=[mindmap_markdown], outputs=[svg_mindmap, pdf_mindmap])
30
+
31
+ if __name__ == "__main__":
32
+ try:
33
+ subprocess.run(['apt', 'install', '-y', 'graphviz'])
34
+ print("Graphviz installed successfully")
35
+ except Exception:
36
+ try:
37
+ subprocess.run(['sudo', 'apt', 'install', '-y', 'graphviz'])
38
+ print("Graphviz installed successfully using sudo")
39
+ except:
40
+ print("Graphviz installation failed")
41
+ sys.exit(1)
42
+ print("Graphviz loaded successfully")
43
+ app.queue(default_concurrency_limit=25).launch(show_error=True)