librelist archives

« back to archive

Aliasing one URL to another

Aliasing one URL to another

From:
Rollin Thomas
Date:
2013-09-25 @ 06:49
Hi.  I would like for the rule

    /chickens/

to just be a simple alias for the commonly used

    /animals/?type=chicken

and without a redirect.  I thought an example of this would be easy to
find, but so far I have not had any luck.  I can only think of hacky ways
of doing this, perhaps there is some deep flask knowledge I have not yet
understood that can help me...?

R

Re: [flask] Aliasing one URL to another

From:
Phil Freo
Date:
2013-09-25 @ 15:46
On Tue, Sep 24, 2013 at 11:49 PM, Rollin Thomas <rcthomas3000@gmail.com>wrote:

> Hi.  I would like for the rule
>
>     /chickens/
>
> to just be a simple alias for the commonly used
>
>     /animals/?type=chicken
>
> and without a redirect.  I thought an example of this would be easy to
> find, but so far I have not had any luck.  I can only think of hacky ways
> of doing this, perhaps there is some deep flask knowledge I have not yet
> understood that can help me...?
>
> R
>

You can have multiple @app.route decorators (one for each path) around your
view function.

Re: [flask] Aliasing one URL to another

From:
Rollin Thomas
Date:
2013-09-25 @ 23:18
Certainly, and that's fine with me, if there is a way to know what route
was triggered from within the view function?

R


On Wed, Sep 25, 2013 at 8:46 AM, Phil Freo <phil@philfreo.com> wrote:

> On Tue, Sep 24, 2013 at 11:49 PM, Rollin Thomas <rcthomas3000@gmail.com>wrote:
>
>> Hi.  I would like for the rule
>>
>>     /chickens/
>>
>> to just be a simple alias for the commonly used
>>
>>     /animals/?type=chicken
>>
>> and without a redirect.  I thought an example of this would be easy to
>> find, but so far I have not had any luck.  I can only think of hacky ways
>> of doing this, perhaps there is some deep flask knowledge I have not yet
>> understood that can help me...?
>>
>> R
>>
>
> You can have multiple @app.route decorators (one for each path) around
> your view function.
>

Re: [flask] Aliasing one URL to another

From:
Nathan M
Date:
2013-09-26 @ 09:59
What about merging both urls into /animals/<animal_race> ? As an user I
would think it cleaner and more logic.
Otherwise, you should investigate the request object, in particular
request.path
and request.url



--
/*
** "What do you despise? By this you are truly known."
**	from Manual of Muad'Dib by the Princess Irulan.
*/



On Thu, Sep 26, 2013 at 1:18 AM, Rollin Thomas <rcthomas3000@gmail.com>wrote:

> Certainly, and that's fine with me, if there is a way to know what route
> was triggered from within the view function?
>
> R
>
>
> On Wed, Sep 25, 2013 at 8:46 AM, Phil Freo <phil@philfreo.com> wrote:
>
>> On Tue, Sep 24, 2013 at 11:49 PM, Rollin Thomas <rcthomas3000@gmail.com>wrote:
>>
>>> Hi.  I would like for the rule
>>>
>>>     /chickens/
>>>
>>> to just be a simple alias for the commonly used
>>>
>>>     /animals/?type=chicken
>>>
>>> and without a redirect.  I thought an example of this would be easy to
>>> find, but so far I have not had any luck.  I can only think of hacky ways
>>> of doing this, perhaps there is some deep flask knowledge I have not yet
>>> understood that can help me...?
>>>
>>> R
>>>
>>
>> You can have multiple @app.route decorators (one for each path) around
>> your view function.
>>
>
>