一切都运转良好我似乎无法找到实际输出的方法而不是整个文本字段只是特定的标题'变量使用micawber进行嵌入。
from flask import Flask, render_template, flash, request, redirect
from micawber.providers import bootstrap_basic
from micawber.contrib.mcflask import add_oembed_filters
app = Flask(__name__)
oembed_providers = bootstrap_basic()
add_oembed_filters(app, oembed_providers)
@app.route('/example/')
def contact():
text = request.args.get('text', 'http://www.youtube.com/watch?v=nda_OSWeyn8')
return render_template("example.html", text=text)
if __name__ == "__main__":
app.run(debug = True, host='0.0.0.0', port=5000, passthrough_errors=True)
这是jinja2部分
<div class="video-border text-center">
<div class="embed-responsive embed-responsive-4by3">
{{ text|oembed(class="embed-responsive-item") }}
</div>
<h5>Video Title</h5>
{{ text|extract_oembed() }}
</div>
以下是视频标题
下的输出([u'http://www.youtube.com/watch?v=nda_OSWeyn8'], {u'http://www.youtube.com/watch?v=nda_OSWeyn8': {u'provider_url': u'http://www.youtube.com/', u'version': u'1.0', u'title': u'Leprechaun in Mobile, Alabama', 'url': u'http://www.youtube.com/watch?v=nda_OSWeyn8', u'type': u'video', u'thumbnail_width': 480, u'height': 344, u'width': 459, u'html': u'<iframe width="459" height="344" src="http://www.youtube.com/embed/nda_OSWeyn8?feature=oembed" frameborder="0" allowfullscreen></iframe>', u'author_name': u'botmib', u'thumbnail_height': 360, u'thumbnail_url': u'http://i.ytimg.com/vi/nda_OSWeyn8/hqdefault.jpg', u'provider_name': u'YouTube', u'author_url': u'http://www.youtube.com/user/botmib'}})