| 263 | return data_uri |
| 264 | |
| 265 | def numpy_array_to_temp_url(img_array): |
| 266 | # create a filename for the temporary file |
| 267 | filename = 'generatedsquare.png' |
| 268 | extension_path = os.path.abspath(__file__) |
| 269 | extension_dir = os.path.dirname(os.path.dirname(extension_path)) |
| 270 | extension_folder = os.path.join(extension_dir,"squares") |
| 271 | if not os.path.exists(extension_folder): |
| 272 | os.makedirs(extension_folder) |
| 273 | # create a path for the temporary file |
| 274 | file_path = os.path.join(extension_folder, filename) |
| 275 | |
| 276 | # convert the array to an image using PIL |
| 277 | img = Image.fromarray(img_array) |
| 278 | |
| 279 | # save the image to the temporary file as PNG |
| 280 | img.save(file_path, format='PNG') |
| 281 | |
| 282 | # create a URL for the temporary file |
| 283 | #url = 'file://' + file_path |
| 284 | |
| 285 | return file_path |
| 286 | |
| 287 | def display_interface(interface): |
| 288 | return interface.display() |