python前端页面显示,python flask在html页面上显示图像

在尝试通过Python Flask应用程序在HTML页面上显示图像时遇到问题。将文件名传递到模板,但图像未显示。解决方案是将图像放在'static'文件夹的子文件夹中,然后在模板中使用<img>标签显示。
摘要由CSDN通过智能技术生成

I am trying to pass a filename of an image and render it on a template,

Although I am passing the actual name through it does not display on the page

@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 )

For example: profilepic_filename = /data/tim/img.jpg

I have tried

{ {profilepic_filename}}

img.jpg')%20%7D%7D

And I have also tried

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值