python - Where to locate user data in Flask application? -


i have flask application user's profile image stored. stored images in static directory so:

application.py templates/ static/userdata/user/icon.png 

though don't think idea because not practice modify static directory in production.

i tried making new userdata folder @ root so:

application.py templates/ static/ userdata/user/icon.png 

though when try access file jinja , html,

<img src="/userdata/user/icon.png"> 

the image not show. why this?

thanks, in advance.

use url_for function

.html

<img src="{{ url_for('userdata', filename='/user/icon.png')}}"> 

.py

from flask import send_file @route('/userdata/<filename:filename>') def get_user_data_files(filename):     return send_file(app.config['user_data_folder'] + filename) 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -