Return images in flask response

from flask import send_file

@app.route('/get_image')
def get_image():
    if request.args.get('type') == '1':
       filename = 'ok.gif'
    else:
       filename = 'error.gif'
    return send_file(filename, mimetype='image/gif')

References
https://stackoverflow.com/questions/8637153/how-to-return-images-in-flask-response
https://pythonprogramming.net/flask-send-file-tutorial/

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.