|
import gradio as gr |
|
|
|
def svg_to_html(svg_file): |
|
|
|
with open(svg_file.name, 'r') as file: |
|
svg_code = file.read() |
|
|
|
|
|
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 |
|
|
|
|
|
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." |
|
) |
|
|
|
|
|
iface.launch() |