SVGhtml / app.py
Felguk's picture
Update app.py
ca4f761 verified
raw
history blame contribute delete
949 Bytes
import gradio as gr
def svg_to_html(svg_file):
# Read the SVG file content
with open(svg_file.name, 'r') as file:
svg_code = file.read()
# Create a basic HTML template with the SVG code embedded
html_content = f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SVG to HTML</title>
</head>
<body>
{svg_code}
</body>
</html>
"""
return html_content, svg_code
# Define the Gradio interface
iface = gr.Interface(
fn=svg_to_html,
inputs=gr.File(label="Upload SVG File"),
outputs=[
gr.Textbox(lines=15, label="Generated HTML"),
gr.HTML(label="SVG Preview")
],
title="SVG to HTML Converter",
description="Upload an SVG file to see the generated HTML code and a preview of the SVG."
)
# Launch the interface
iface.launch()