我正在尝试传递一个图片文件的文件名并将其渲染在模板上, 尽管我通过参数传递了实际名称,但它没有显示在页面上。
@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>
两者都没有起作用。
Process finished with exit code 0
,但是localhost:5000
没有显示任何图像。 - Nathan majicvr.comlocalhost:5000
就可用。可能有些东西停止了程序,你会看到Process finished with exit code 0
。 - arshovon