Update app.py
Browse files
app.py
CHANGED
@@ -40,7 +40,11 @@ Generate the correct code, ensure it is free from construct error and this kind
|
|
40 |
|
41 |
svg_code = completion.choices[0].message.content.strip()
|
42 |
full_svg_code = f"<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%' viewBox='0 0 1000 400'>{svg_code}</svg>"
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
# Convert the SVG code to PNG using CairoSVG
|
45 |
png_filename = "diagram.png"
|
46 |
cairosvg.svg2png(bytestring=full_svg_code.encode('utf-8'), write_to=png_filename)
|
|
|
40 |
|
41 |
svg_code = completion.choices[0].message.content.strip()
|
42 |
full_svg_code = f"<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%' viewBox='0 0 1000 400'>{svg_code}</svg>"
|
43 |
+
|
44 |
+
# Save the SVG code to a file for record and future editing
|
45 |
+
with open("diagram.svg", "w") as f:
|
46 |
+
f.write(full_svg_code)
|
47 |
+
|
48 |
# Convert the SVG code to PNG using CairoSVG
|
49 |
png_filename = "diagram.png"
|
50 |
cairosvg.svg2png(bytestring=full_svg_code.encode('utf-8'), write_to=png_filename)
|