librelist archives

« back to archive

redirecting in flask

redirecting in flask

From:
Mohit Singh
Date:
2013-03-06 @ 19:57
Hi,

 Lets say i have a template which contains one button..

But when i click on that button it should take me to (say) google.com
So i dont have the template for that site..
so lets say my view is
@app.route("/")
def hello():
     #return ???what???

Thanks

-- 
Mohit

"When you want success as badly as you want the air, then you will get it.
There is no other secret of success."
-Socrates

Re: [flask] redirecting in flask

From:
Michael Davis
Date:
2013-03-06 @ 20:06
You can return straight html if you really want to.

    @app.route("/")
    def hello():
        return "<html><body><a href="http://www.google.com
>Google</a></body></html>

---
Michael Davis
Software Engineering - Iowa State University
WebFilings Software Engineer Intern
IASG Treasurer


On Wed, Mar 6, 2013 at 1:57 PM, Mohit Singh <mohit1007@gmail.com> wrote:

> Hi,
>
>  Lets say i have a template which contains one button..
>
> But when i click on that button it should take me to (say) google.com
> So i dont have the template for that site..
> so lets say my view is
> @app.route("/")
> def hello():
>      #return ???what???
>
> Thanks
>
> --
> Mohit
>
> "When you want success as badly as you want the air, then you will get it.
> There is no other secret of success."
> -Socrates
>

Re: [flask] redirecting in flask

From:
Mohit Singh
Date:
2013-03-06 @ 20:08
Great thanks :)


On Wed, Mar 6, 2013 at 12:06 PM, Michael Davis
<mike.philip.davis@gmail.com>wrote:

> You can return straight html if you really want to.
>
>
>     @app.route("/")
>     def hello():
>         return "<html><body><a href="http://www.google.com
> >Google</a></body></html>
>
> ---
> Michael Davis
> Software Engineering - Iowa State University
> WebFilings Software Engineer Intern
> IASG Treasurer
>
>
> On Wed, Mar 6, 2013 at 1:57 PM, Mohit Singh <mohit1007@gmail.com> wrote:
>
>> Hi,
>>
>>  Lets say i have a template which contains one button..
>>
>> But when i click on that button it should take me to (say) google.com
>> So i dont have the template for that site..
>> so lets say my view is
>> @app.route("/")
>> def hello():
>>      #return ???what???
>>
>> Thanks
>>
>> --
>> Mohit
>>
>> "When you want success as badly as you want the air, then you will get
>> it. There is no other secret of success."
>> -Socrates
>>
>
>


-- 
Mohit

"When you want success as badly as you want the air, then you will get it.
There is no other secret of success."
-Socrates

Re: [flask] redirecting in flask

From:
Shawn Milochik
Date:
2013-03-06 @ 20:09
And if you want to be really silly, you can return HTML with a meta
redirect tag. Others have given better suggestions, but for the sake
of completeness...

<-- redirect user to Google after five seconds -->
<META http-equiv="refresh" content="5;URL=http://google.com">

Re: [flask] redirecting in flask

From:
Steven Kryskalla
Date:
2013-03-06 @ 20:01
On Wed, Mar 6, 2013 at 11:57 AM, Mohit Singh <mohit1007@gmail.com> wrote:
> Hi,
>
>  Lets say i have a template which contains one button..
>
> But when i click on that button it should take me to (say) google.com
> So i dont have the template for that site..
> so lets say my view is
> @app.route("/")
> def hello():
>      #return ???what???
>

Why do you need to use flask for that? It sounds like you could just use a link:

<a href="http://www.google.com">Google</a>

If you really want to use flask, look into flask.redirect.