librelist archives

« back to archive

how to check what URL we are on?

how to check what URL we are on?

From:
Charlie Reddington
Date:
2012-04-14 @ 12:26
Hi,

I'd like to do something in templates like this (method #1) ->

http://stackoverflow.com/questions/2919709/php-html-css-beginner-use-case-switch-if-else-need-advice

Does flask /jinja2 have something similar? ($page)

Charlie

Re: [flask] how to check what URL we are on?

From:
Armin Ronacher
Date:
2012-04-14 @ 12:36
On 4/14/12 1:26 PM, Charlie Reddington wrote:
> Hi,
> 
> I'd like to do something in templates like this (method #1)
> 
->http://stackoverflow.com/questions/2919709/php-html-css-beginner-use-case-switch-if-else-need-advice
> 
> Does flask /jinja2 have something similar? ($page)
That's not Jinja2, that's Flask:

{{ request.url }}
{{ request.base_url }}
{{ request.url_root }}
{{ request.host_url }}

Pick one.


Regards,
Armin

Re: [flask] how to check what URL we are on?

From:
Simon Sapin
Date:
2012-04-14 @ 12:52
Le 14/04/2012 14:36, Armin Ronacher a écrit :
> {{ request.url }}
> {{ request.base_url }}
> {{ request.url_root }}
> {{ request.host_url }}
>
> Pick one.

I often use {{ request.path }} for this purpose.
http://flask.pocoo.org/docs/api/#flask.Request.path

-- 
Simon Sapin

Re: [flask] how to check what URL we are on?

From:
Charlie Reddington
Date:
2012-04-14 @ 12:59
Thanks guys! This is exactly what I'm looking for.

On Sat, Apr 14, 2012 at 8:52 AM, Simon Sapin <simon.sapin@exyr.org> wrote:

> Le 14/04/2012 14:36, Armin Ronacher a écrit :
> > {{ request.url }}
> > {{ request.base_url }}
> > {{ request.url_root }}
> > {{ request.host_url }}
> >
> > Pick one.
>
> I often use {{ request.path }} for this purpose.
> http://flask.pocoo.org/docs/api/#flask.Request.path
>
> --
> Simon Sapin
>