librelist archives

« back to archive

How to get full url

How to get full url

From:
Alex
Date:
2011-05-28 @ 07:08
Hi everyone,
I want to get a full url.
Flask provides url_for for a relative url.
I know request.url stores the full url.But i can't have the request object
in a static function.
Is there another way to get the full url or the site's base url.
thanks.

Re: [flask] How to get full url

From:
Ron DuPlain
Date:
2011-05-28 @ 07:22
On Sat, May 28, 2011 at 3:08 AM, Alex <gfreezy@gmail.com> wrote:
> Hi everyone,
> I want to get a full url.
> Flask provides url_for for a relative url.
> I know request.url stores the full url.But i can't have the request object
> in a static function.
> Is there another way to get the full url or the site's base url.
> thanks.

You can generate full URLs with _external=True in url_for.
http://flask.pocoo.org/docs/api/#flask.url_for

The server name here is taken from SERVER_NAME in the app config.

-Ron