Re: [flask] Dynamic subdomain
- From:
- Nicolas Clairon
- Date:
- 2011-02-22 @ 15:51
Hi,
Thank you for your answers. The Site object is pretty interesting.
About passing the subdomain to the route, this is what I expected. But
I tried to implement it in a simple app without success :
http://paste.pocoo.org/show/342835/
This example don't work either on
fr.localhost:5000
en.localhost:5000
or
localhost:5000
Am I missing something ?
N.
On Tue, Feb 22, 2011 at 3:35 PM, Simon Sapin <simon.sapin@exyr.org> wrote:
> Le 22/02/2011 23:09, Nicolas Clairon a écrit :
>> Hi,
>>
>> Is there a way to implement dynamic subdomain with Flask ? I'd like to
>> do something like that:
>>
>> python.example.com
>> apple.example.com
>> -> get the subdomain name and do something with that
>>
>> instead of
>> example.com/apple
>
> Hi,
>
> Extra parameters you pass to @app.route() and friends are passed
> directly to Werkzeug’s Rule class:
> http://werkzeug.pocoo.org/docs/routing/#werkzeug.routing.Rule
>
> You can restrict a rule to a given subdomain pattern, and this pattern
> can contain variable parts the same way that URL patterns do:
>
> @app.route('/foo', subdomain='<bar>')
> def foo(bar):
> # ...
>
> Regards,
> --
> Simon Sapin
> http://exyr.org
>
Re: [flask] Dynamic subdomain
- From:
- Julen Ruiz Aizpuru
- Date:
- 2011-02-22 @ 16:11
ar., 2011.eko otsren 22a 16:51(e)an, Nicolas Clairon(e)k idatzi zuen:
> Hi,
>
> Thank you for your answers. The Site object is pretty interesting.
>
> About passing the subdomain to the route, this is what I expected. But
> I tried to implement it in a simple app without success :
>
> http://paste.pocoo.org/show/342835/
>
> This example don't work either on
>
> fr.localhost:5000
> en.localhost:5000
> or
> localhost:5000
>
> Am I missing something ?
>
Your example works fine if you add fr.localhost and en.localhost to your
/etc/hosts file.
j.
Re: [flask] Dynamic subdomain
- From:
- Nicolas Clairon
- Date:
- 2011-02-22 @ 16:18
Gosh ! I forgot to make the changes. I think it's coffee time :)
Thank you for your helpful answers.
On Tue, Feb 22, 2011 at 5:11 PM, Julen Ruiz Aizpuru <julenx@gmail.com> wrote:
> ar., 2011.eko otsren 22a 16:51(e)an, Nicolas Clairon(e)k idatzi zuen:
>> Hi,
>>
>> Thank you for your answers. The Site object is pretty interesting.
>>
>> About passing the subdomain to the route, this is what I expected. But
>> I tried to implement it in a simple app without success :
>>
>> http://paste.pocoo.org/show/342835/
>>
>> This example don't work either on
>>
>> fr.localhost:5000
>> en.localhost:5000
>> or
>> localhost:5000
>>
>> Am I missing something ?
>>
>
> Your example works fine if you add fr.localhost and en.localhost to your
> /etc/hosts file.
>
> j.
>