freefly0313
freefly0313

Reputation: 105

Invalid url with url_for

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)

Upvotes: 1

Views: 977

Answers (1)

Christopher Su
Christopher Su

Reputation: 373

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.

Upvotes: 1

Related Questions