Search code examples
pythongoogle-app-enginewebapp2

Google appengine. How to redirect inside handler constructor


I have simple handler class:

class my_handler(webapp2.RequestHandler):
    def __init__(self, *args, **kwargs):
        super(my_handler, self).__init__(*args, **kwargs)
        self.redirect("/")

but redirrect doesn't work. What is the bast way to do it?


Solution

  • You should override dispatch instead, and redirect instead of calling super().