url_for的网址无效

时间:2017-05-25 16:16:10

标签: python flask python-requests url-for

我在Python Flask中使用url_for遇到错误。错误如下: MissingSchema: Invalid URL

不确定是什么问题。这是我的代码:

@app.route("/", methods=('GET', 'POST'))
def landing():
    form = forms.OptinForm()
    if form.validate_on_submit():
        requests.get(url_for('indoctrination', email=form.email.data, name=form.first_name.data))
    return render_template('index.html', form=form)

1 个答案:

答案 0 :(得分:0)

在您的使用中,url_for返回的是/some/example之类的相对路径。 requests.get需要完整的绝对路径,例如http://example.com/some/path。您可能希望在相对路径前添加基本URL。

相关问题