【发布时间】:2020-10-05 02:51:39
【问题描述】:
我正在做一个项目,对烧瓶比较陌生。我有一个输出数据框的 python 脚本,这一切都适用于我的 HTML 代码。我遇到的问题是我需要重新路由到外部链接。如果我输出指向诸如变量 =“www.google.com”之类的站点的链接,我的烧瓶代码可以正常工作,但它确实可以与变量 = 预测 ['Link'][0] 一起正常工作。我得到 http://127.0.0.1:5000/stringOutputofPrediction 而不是 http://stringOutputofPrediction 任何帮助将不胜感激,因为我已经把头撞在墙上几个小时了。 这是我的html代码:
<div class="inner">
<h3>{{prediction['Episode'][0]}}</h3>
<p>{{prediction['Description'][0]}}</p>
<a href= "{{ url_for('go_outside_flask_method', variable = prediction['Link'][0]) }}" >Watch</a>
</div>
Flask/Python 脚本:
@app.route('/<string:variable>',)
def go_outside_flask_method(variable):
variable = 'https://'+ variable
return redirect(variable, code = 307)
【问题讨论】: