MarkdownToSVG / app.py
raannakasturi's picture
Replace apt installation command for Graphviz with apt-get in app.py
eaa1129
import gradio as gr
from generate_svg import main
theme = gr.themes.Soft(
primary_hue="purple",
secondary_hue="cyan",
neutral_hue="slate",
font=[
gr.themes.GoogleFont("Syne"),
gr.themes.GoogleFont("Poppins"),
gr.themes.GoogleFont("Poppins"),
gr.themes.GoogleFont("Poppins")
],
)
with gr.Blocks(theme=theme, title="MarkDown SVG Generator", fill_height=True) as app:
gr.HTML(
value ="""
<h1 style="text-align: center;">MarkDown SVG Generator<p style="text-align: center;">Designed and Developed by <a href="https://raannakasturi.eu.org" target="_blank" rel="nofollow noreferrer external">Nayan Kasturi</a></p> </h1>
<p style="text-align: center;">MarkDown SVG Generator for ReXplore</p>
""")
with gr.Row():
with gr.Column():
markdown = gr.Textbox(label="Markdown Text", placeholder="Enter the markdown text", lines=7)
get_file = gr.Button(value="SVG File", variant="primary")
svg_viewer = gr.Textbox(label="SVG Viewer", placeholder="SVG Viewer", lines=7, interactive=False, show_copy_button=True)
get_file.click(
main,
inputs=[markdown],
outputs=[svg_viewer],
concurrency_limit=25,
scroll_to_output=True,
show_api=True,
api_name="markdown_svg_generator",
show_progress="full",
)
import subprocess
try:
subprocess.run(["apt", "update"], check=True)
subprocess.run(["apt-get", "install", "-y", "graphviz"], check=True)
app.queue(default_concurrency_limit=25).launch(show_api=True, show_error=True, debug=True)
except subprocess.CalledProcessError:
print("Graphviz is not installed. Please install it using `apt install graphviz` and try again.")
except Exception as e:
print(f"An error occurred: {e}")
raise e