Jeremy Thiesen
Jeremy Thiesen

Reputation: 167

Pyramid Direct User to DIfferent Domain

I would like to redirect my user to another domain. For example: my site is http://www.mysite.com/ and I would like to redirect them to http://www.google.com/.

I want the redirect to come after a form submission. Is this possible in the pyramid web framework?

Or is the best route to use an AJAX post request to the server and then redirect using javascript?

Thank you.

Upvotes: 0

Views: 190

Answers (1)

Antoine Leclair
Antoine Leclair

Reputation: 18050

Return HTTPFound with the location you want after your successful form submission.

from pyramid.httpexceptions import HTTPFound

def form_received_here(request):
    # do stuff here
    return HTTPFound('http://example.com')

This will return a status code 302 with a Location header set to http://example.com.

Upvotes: 2

Related Questions