From 0bbfdd4c880c0ef3b4c35fcd7e2e7b25e27ed27a Mon Sep 17 00:00:00 2001 From: Dan Collins Date: Thu, 7 Nov 2024 19:20:12 -0500 Subject: [PATCH] thrimshim: use send_file to serve templates from database --- thrimshim/thrimshim/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/thrimshim/thrimshim/main.py b/thrimshim/thrimshim/main.py index 99c1190..54faaa3 100644 --- a/thrimshim/thrimshim/main.py +++ b/thrimshim/thrimshim/main.py @@ -628,7 +628,12 @@ def get_template(name): image = row[0] logging.info('Thumbnail image of {} fetched'.format(name)) - return flask.Response(image, mimetype='image/png') + return flask.send_file( + io.BytesIO(image), + mimetype='image/png', + as_attachment=False, + download_name=f'{name}.png' + ) @app.route('/thrimshim/template-metadata/')