redirect('http://www.google.com') doesn't take to google homepage

103 views
Skip to first unread message

Praveen Subramanian

unread,
Sep 11, 2011, 1:19:33 AM9/11/11
to tipfy
Hi,

The following snippet of code doesn't take me to the google home page.
I even tried with "return redirect('http://www.google.com'). Any
pointers?

from tipfy import (RequestHandler, Response,
render_json_response,redirect)
.....
......
........
response = redirect('http://www.google.com')
logging.info(response)
logging.info(response.status_code)
logging.info(response.headers)


Thanks,
Praveen

Rodrigo Moraes

unread,
Sep 11, 2011, 4:41:58 AM9/11/11
to tipfy
On Sep 11, 2:19 am, Praveen Subramanian wrote:
> Hi,
>
> The following snippet of code doesn't take me to the google home page.
> I even tried with "return redirect('http://www.google.com'). Any
> pointers?

Hi,
I think you are confusing the purpose of redirect(). It doesn't
perform HTTP requests. It just prints out a header with a Location
field so that browsers redirect to the provided URL.

To get the contents of an external page, you must do an HTTP request.
On App Engine you use the urlfetch service for that, or urllib/
urllib2.

Hope this helps.
-- rodrigo

Praveen Subramanian

unread,
Sep 11, 2011, 12:38:54 PM9/11/11
to tipfy
Thanks Rodrigo. Let me try it out this way.

On Sep 11, 1:41 am, Rodrigo Moraes <rodrigo.mor...@gmail.com> wrote:
> On Sep 11, 2:19 am, Praveen Subramanian wrote:
>
> > Hi,
>
> > The following snippet of code doesn't take me to the google home page.
> > I even tried with "returnredirect('http://www.google.com'). Any
> > pointers?
>
> Hi,
> I think you are confusing the purpose ofredirect().  It doesn't
> perform HTTP requests. It just prints out a header with a Location
> field so that browsersredirectto the provided URL.
Reply all
Reply to author
Forward
0 new messages