【发布时间】:2018-03-28 20:54:54
【问题描述】:
我正在尝试传递图像的文件名并将其呈现在模板上, 虽然我通过实际名称传递它并没有显示在页面上
@app.route('/', methods=['GET','POST'])
@app.route('/start', methods=['GET','POST'])
def start():
person_to_show = 'tim'
profilepic_filename = os.path.join(people_dir, person_to_show, "img.jpg")
return render_template('start.html',profilepic_filename =profilepic_filename )
例如:profilepic_filename = /data/tim/img.jpg 我试过了
{{profilepic_filename}}
<img src="{{ url_for('data', filename='tim/img.jpg') }}"></img>
我也试过了
<img src="{{profilepic_filename}}"></img>
两者都不起作用
【问题讨论】:
标签: python html flask flash-message