I'm trying to do a simple redirection after logging the user. I thought I could use the print "Location:..." method but that doesn't seem to do the trick.
class MainPage(webapp.RequestHandler):
def get(self):
ip = self.request.remote_addr
log = Log()
log.ip_address = ip
log.put()
print "Location:http://www.appurl.com"
RequestHandler
has a redirect()
method that you can use. It takes two parameters, the first one being the url to redirect to, and the second one a boolean value. If you pass true, it sends a 301 code to indicate a permanent redirect, if you don't pass it an explicit value, it defaults to false, and sends the client a 302 code to indicate a temporary redirect.
Something like this:
class MainPage(webapp.RequestHandler):
def get(self):
ip = self.request.remote_addr
log = Log()
log.ip_address = ip
log.put()
self.redirect("http://www.appurl.com") # replaced this -> print "Location:http://www.appurl.com"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With