J.Olufsen
J.Olufsen

Reputation: 13915

How to refresh or redirect browser to specified URL in Python?

There is similar function in PHP:

header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.example.com/');
exit();

How to properly redirect browser to new page or refresh current one?


I am using Google App Engine Framework.

Upvotes: 0

Views: 2515

Answers (2)

David Robinson
David Robinson

Reputation: 78610

This page explains how to use redirects in the Google App Engine Framework, using the redirect method of the webapp.RequestHandler. The most relevant code is:

class FormHandler(webapp.RequestHandler):
    def post(self):
        if processFormData(self.request):
            self.redirect("/home")
        else:
            # Display the form, possibly with error messages.

You should read the whole page to see how it fits into your app.

Upvotes: 3

Has QUIT--Anony-Mousse
Has QUIT--Anony-Mousse

Reputation: 77454

Try sending a body, too. E.g. an empty one, just to send the newline separator.

Upvotes: 0

Related Questions