Felguk commited on
Commit
c75d598
·
verified ·
1 Parent(s): a0b79ea

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def svg_to_html(svg_file):
4
+ # Read the SVG file content
5
+ with open(svg_file.name, 'r') as file:
6
+ svg_code = file.read()
7
+
8
+ # Create a basic HTML template with the SVG code embedded
9
+ html_content = f"""
10
+ <!DOCTYPE html>
11
+ <html lang="en">
12
+ <head>
13
+ <meta charset="UTF-8">
14
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
15
+ <title>SVG to HTML</title>
16
+ </head>
17
+ <body>
18
+ {svg_code}
19
+ </body>
20
+ </html>
21
+ """
22
+ return html_content, svg_code
23
+
24
+ # Define the Gradio interface
25
+ iface = gr.Interface(
26
+ fn=svg_to_html,
27
+ inputs=gr.inputs.File(label="Upload SVG File"),
28
+ outputs=[
29
+ gr.outputs.Textbox(lines=15, label="Generated HTML"),
30
+ gr.outputs.HTML(label="SVG Preview")
31
+ ],
32
+ title="SVG to HTML Converter",
33
+ description="Upload an SVG file to see the generated HTML code and a preview of the SVG",
34
+ theme=Nymbo/Nymbo_theme_5
35
+ )
36
+
37
+ # Launch the interface
38
+ iface.launch()