Invalid url with url_for

Question:

I am running into an error using url_for with Python Flask. the error reads:
MissingSchema: Invalid URL

Not sure what the issue is. Here is my code:

@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)
Asked By: freefly0313

||

Answers:

In your usage, url_for is returning a relative path like /some/example . requests.get expects a full, absolute path, like http://example.com/some/path. You probably want to add your base url in front of the relative path.

Answered By: Christopher Su
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.