Update app.py
Browse files
app.py
CHANGED
|
@@ -8,8 +8,14 @@ import json
|
|
| 8 |
import re
|
| 9 |
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
#
|
| 13 |
def execute_code(code):
|
| 14 |
namespace = {}
|
| 15 |
exec(code, namespace)
|
|
|
|
| 8 |
import re
|
| 9 |
|
| 10 |
|
| 11 |
+
def get_image_data(fig):
|
| 12 |
+
buf = io.BytesIO()
|
| 13 |
+
fig.savefig(buf, format='png')
|
| 14 |
+
buf.seek(0)
|
| 15 |
+
img = Image.open(buf)
|
| 16 |
+
return img
|
| 17 |
|
| 18 |
+
# Execute Python code and generate images
|
| 19 |
def execute_code(code):
|
| 20 |
namespace = {}
|
| 21 |
exec(code, namespace)
|