我正在尝试在我的Flask应用程序中添加一个嵌入的YouTube视频。在
数据库存储YouTube的URL
这是我的模型:
class Post(db.Model):
id = db.Column(db.Integer, primary_key = True)
video = db.Column(db.String(450))
@app.route('/post/<id>')
def post(id):
post = Post.query.filter_by(id=id).first()
return render_template('post.html', post = post)
我的模板:
^{pr2}$示例:
数据库中存储的URL:
id|video
1 |https://www.youtube.com/watch?v=Q5XvLJrW6Fg
在web浏览器中呈现:
<iframe src="https://www.youtube.com/watch?v=Q5XvLJrW6Fg" allowfullscreen="" width="100%" frameborder="0"></iframe>
但不能显示视频。在
你应该使用视频的嵌入链接。在这种情况下
相关问题 更多 >
编程相关推荐