Spaces:
Running
Running
File size: 1,558 Bytes
0536e96 c7bbcef 0536e96 c7bbcef 0536e96 c7bbcef 0536e96 c7bbcef 0536e96 b3599a0 4d016ee 0d50184 0536e96 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import sys
from generate_mindmap import generate_mindmap
import gradio as gr
import subprocess
def generate(mindmap_markdown):
mindmap_svg, mindmap_pdf = generate_mindmap(mindmap_markdown)
with open(mindmap_svg, 'rb') as f:
svg_mindmap = f.read()
with open(mindmap_pdf, 'rb') as f:
pdf_mindmap = f.read()
return str(svg_mindmap), str(pdf_mindmap)
theme = gr.themes.Soft(
primary_hue="purple",
secondary_hue="cyan",
neutral_hue="slate",
font=[gr.themes.GoogleFont('Syne'), gr.themes.GoogleFont('Poppins')],
)
with gr.Blocks(theme=theme, title="Binary Biology") as app:
with gr.Row():
with gr.Column():
mindmap_markdown = gr.Textbox(label="Mindmap Markdown", placeholder="Enter the markdown for the mindmap", lines=10)
btn_generate_mindmap = gr.Button(value="Generate Mindmap") # Renamed button here
with gr.Column():
svg_mindmap = gr.TextArea(label="SVG Mindmap", placeholder="The SVG representation of the mindmap", lines=10)
pdf_mindmap = gr.TextArea(label="PDF Mindmap", placeholder="The PDF representation of the mindmap", lines=10)
btn_generate_mindmap.click(generate, inputs=[mindmap_markdown], outputs=[svg_mindmap, pdf_mindmap])
if __name__ == "__main__":
subprocess.run(['apt-get', 'update'])
subprocess.run(['apt-get', 'install', '-y', 'graphviz'], check=True)
print("Graphviz installed successfully")
print("Graphviz loaded successfully")
app.queue(default_concurrency_limit=25).launch(show_error=True)
|