Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to send image to template thats not in static flask

from config import directory_to_image_folder

#first create the route
@app.route('/uploads/<path:filename>')
def download_file(filename):
    return send_from_directory(directory_to_image_folder, filename, as_attachment=True)

#add this to the template inside of an image tag
<img width="100%" height="100%" src="{{ url_for('download_file', filename='name_of_image.extension') }}">
Comment

PREVIOUS NEXT
Code Example
Python :: how to get the memory location of a varible in python 
Python :: python logging change handler level 
Python :: python zip file 
Python :: reverse a number in python 
Python :: python indian currency formatter 
Python :: migrate database in django 
Python :: pandas split column fixed width 
Python :: python button graphics.py 
Python :: discord.py add avatar to embed 
Python :: copy module in python 
Python :: Binary search tree deleting in python 
Python :: noob python 
Python :: add a row at a specific index pandas 
Python :: python "urllib3" download and save pdf 
Python :: assert in selenium python 
Python :: how to add find the smallest int n in a list python 
Python :: scipy.stats.spearmanr 
Python :: python plot normal distribution 
Python :: tri fusion python code 
Python :: NumPy bitwise_xor Syntax 
Python :: Python NumPy transpose Function Syntax 
Python :: python stop stdout 
Python :: python find all occurrence in string 
Python :: input check in pygame 
Python :: update dataframe based on value from another dataframe 
Python :: 20 minute timer with python 
Python :: how to install python packages in local directory 
Python :: us states and capitals dictionary 
Python :: Using python-poppler 
Python :: maximun row and columns in python 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =