Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google app engine redirect to an absolut uri

I am using google app engine with python and webapp2, and i can't find the way just to redirect to an external web site using an absolute uri.

For example:

class Landing(BaseHandler):
    def get(self):     
        self.render("landing.html")

    def post(self):
        name=self.request.get("name")
        if name == "yes"
            self.redirect("/")
        else:
            self.redirect("http://example.com") **This is the problem as I want to redirect to an absolute url.

The self.redirect always redirects to a relative url. How could I do a redirection to an absolute url? I think it has to be easy but I can't find the way.

like image 713
Jesus Benavent Avatar asked Oct 22 '22 20:10

Jesus Benavent


2 Answers

Works fine for me and does not only redirect to a relative url. Please check your config of your host, browser and caching.

GAE just redirected me to example.com using it on my dev and production server

Take care though that example.com redirects to http://www.iana.org/domains/example/

That might be confusing you.

Try using eg self.redirect("http://www.facebook.com"). That will redirect you to facebook. Simple.

like image 50
Jimmy Kane Avatar answered Oct 27 '22 09:10

Jimmy Kane


Also.. I think I may have been bitten by the fact that there is no return in your code - so even after you've called the self.redirect(...) bit, if you write anything else to self, that may mess up your redirect.

like image 39
Richard Green Avatar answered Oct 27 '22 09:10

Richard Green