Download app.py from Felguk/SVGhtml: direct link, hf CLI and curl.
- Browser
- Download file 949 Bytes
-
https://huggingface.co/spaces/Felguk/SVGhtml/resolve/main/app.py
- Command line
-
hf download hf://spaces/Felguk/SVGhtml/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Felguk/SVGhtml/resolve/main/app.py
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() |