For learning purposes, I\'m creating a site using Python+Flask. I want to recover an image from database and show it on screen. But one step at a time.
I have no idea ho
that's my solution, it can work in my website:
@main.route('/upload', methods=['GET', 'POST'])
def upload_avatar():
if request.method == 'POST':
file = request.files['file']
if file and allowed_file(file.filename):
current_user.avatar_local = file.read()
db.session.add(current_user)
db.session.commit()
return redirect(url_for('main.user_page', username=current_user.username))
return render_template('upload_avatar.html', user=current_user)
using Flask,Flask-Alchemy to handle database.
{% block edit_avatar %}
{% endblock %}
that's html file.you can embed it in you html.