File size: 949 Bytes
c75d598
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ca4f761
 
 
 
 
 
 
 
 
 
 
c75d598
 
 
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 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()