flask access images code example
Example 1: how to add images in hml while using flask
<image src="{{url_for('static',filename = 'images/download.jpg')}}" >
<!--filename = "path of your image in in static folder"-->
Example 2: how to send image to template thats not in static flask
from config import directory_to_image_folder
@app.route('/uploads/<path:filename>')
def download_file(filename):
return send_from_directory(directory_to_image_folder, filename, as_attachment=True)
<img width="100%" height="100%" src="{{ url_for('download_file', filename='name_of_image.extension') }}">