Layout.html的一部分将显示用户名和注销选项,但是不会显示个人资料图片。 src没有进行函数调用,该函数将返回配置文件pic路径
layout.html
<a href="{{ url_for('users.account')}}"> <img src="{{ url_for ('get_profile_pic') }}"></a>
@users.route("/get_profile_pic", methods=['GET', 'POST'])
def get_profile_pic():
logged_in_user = users.find_one({'username': current_user.username})
profile_pic_path = logged_in_user['profile_pic']
return profile_pic_path