librelist archives

« back to archive

Application mount point

Application mount point

From:
Manel Villar
Date:
2011-07-22 @ 13:00
Hi,

I have an application running on Cherokee Server on
domain.com/nasbackend/login, but when I redirect using url_for, I get the
url domain.com/login . How can I declare a mount point for the app?

Thanks,


-- 
Manel Villar
Cerca,74 1ºD
15365 Cariño
A Coruña (Spain)
Tel: (+34) 636863621
manelvf@gmail.com

*"Ars longa, vita brevis"*

Re: [flask] Application mount point

From:
Daniel , Dao Quang Minh
Date:
2011-07-22 @ 13:34
You should use DispatcherMiddleware to declare nasbackend as the prefix

http://flask.pocoo.org/docs/patterns/appdispatch/#combining-applications

Cheers,
Daniel, Dao Quang Minh

On Fri, Jul 22, 2011 at 9:00 PM, Manel Villar <manelvf@gmail.com> wrote:

> Hi,
>
> I have an application running on Cherokee Server on
> domain.com/nasbackend/login, but when I redirect using url_for, I get the
> url domain.com/login . How can I declare a mount point for the app?
>
> Thanks,
>
>
> --
> Manel Villar
> Cerca,74 1ºD
> 15365 Cariño
> A Coruña (Spain)
> Tel: (+34) 636863621
> manelvf@gmail.com
>
> *"Ars longa, vita brevis"*
>
>

Re: [flask] Application mount point

From:
Manel Villar
Date:
2011-07-22 @ 20:30
After looking your link and

http://librelist.com/browser//flask/2011/2/23/soaplib-with-flask/#be4f113dea07ce4e02911c217e1f21ba

this is my code:

from nas_backend import app
from nas_backend import app as backend


if __name__ == '__main__':
    backend.wsgi_app = DispatcherMiddleware(app.wsgi_app, {
      '/nasbackend': backend.wsgi_app
      })
    backend.run(debug=True, host="0.0.0.0")

and it fails (maximum recursion)

I only use one application since I only want the mount point (other mount
points are used for other non-flask apps in production).


2011/7/22 Daniel , Dao Quang Minh <dqminh89@gmail.com>

> You should use DispatcherMiddleware to declare nasbackend as the prefix
>
> http://flask.pocoo.org/docs/patterns/appdispatch/#combining-applications
>
> Cheers,
> Daniel, Dao Quang Minh
>
>
> On Fri, Jul 22, 2011 at 9:00 PM, Manel Villar <manelvf@gmail.com> wrote:
>
>> Hi,
>>
>> I have an application running on Cherokee Server on
>> domain.com/nasbackend/login, but when I redirect using url_for, I get the
>> url domain.com/login . How can I declare a mount point for the app?
>>
>> Thanks,
>>
>>
>> --
>> Manel Villar
>> Cerca,74 1ºD
>> 15365 Cariño
>> A Coruña (Spain)
>> Tel: (+34) 636863621
>> manelvf@gmail.com
>>
>> *"Ars longa, vita brevis"*
>>
>>
>


-- 
Manel Villar
Cerca,74 1ºD
15365 Cariño
A Coruña (Spain)
Tel: (+34) 636863621
manelvf@gmail.com

*"Ars longa, vita brevis"*

Re: [flask] Application mount point

From:
Manel Villar
Date:
2011-07-23 @ 11:14
Now using a variant of 1st code sample on
https://github.com/mitsuhiko/flask/issues/225 it works.

I think it's better explained in this issue thant in the docs.

2011/7/22 Manel Villar <manelvf@gmail.com>

> After looking your link and
> 
http://librelist.com/browser//flask/2011/2/23/soaplib-with-flask/#be4f113dea07ce4e02911c217e1f21ba
>
> this is my code:
>
> from nas_backend import app
> from nas_backend import app as backend
>
>
> if __name__ == '__main__':
>     backend.wsgi_app = DispatcherMiddleware(app.wsgi_app, {
>       '/nasbackend': backend.wsgi_app
>       })
>     backend.run(debug=True, host="0.0.0.0")
>
> and it fails (maximum recursion)
>
> I only use one application since I only want the mount point (other mount
> points are used for other non-flask apps in production).
>
>
> 2011/7/22 Daniel , Dao Quang Minh <dqminh89@gmail.com>
>
> You should use DispatcherMiddleware to declare nasbackend as the prefix
>>
>> http://flask.pocoo.org/docs/patterns/appdispatch/#combining-applications
>>
>> Cheers,
>> Daniel, Dao Quang Minh
>>
>>
>> On Fri, Jul 22, 2011 at 9:00 PM, Manel Villar <manelvf@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I have an application running on Cherokee Server on
>>> domain.com/nasbackend/login, but when I redirect using url_for, I get
>>> the url domain.com/login . How can I declare a mount point for the app?
>>>
>>> Thanks,
>>>
>>>
>>> --
>>> Manel Villar
>>> Cerca,74 1ºD
>>> 15365 Cariño
>>> A Coruña (Spain)
>>> Tel: (+34) 636863621
>>> manelvf@gmail.com
>>>
>>> *"Ars longa, vita brevis"*
>>>
>>>
>>
>
>
> --
> Manel Villar
> Cerca,74 1ºD
> 15365 Cariño
> A Coruña (Spain)
> Tel: (+34) 636863621
> manelvf@gmail.com
>
> *"Ars longa, vita brevis"*
>
>


-- 
Manel Villar
Cerca,74 1ºD
15365 Cariño
A Coruña (Spain)
Tel: (+34) 636863621
manelvf@gmail.com

*"Ars longa, vita brevis"*

Re: [flask] Application mount point

From:
Ron DuPlain
Date:
2011-07-23 @ 15:43
On Sat, Jul 23, 2011 at 7:14 AM, Manel Villar <manelvf@gmail.com> wrote:
> Now using a variant of 1st code sample on
> https://github.com/mitsuhiko/flask/issues/225 it works.
>
> I think it's better explained in this issue thant in the docs.

What can we do to improve the docs?  The snippet you are using from
that issue is taken verbatim from the docs.  Reviewing the docs, we
could promote werkzeug.wsgi.DispatcherMiddleware in the Dispatch By
Path section since it is much simpler, and provide the current
PathDispatcher (or similar) which provides for a default app.

Or maybe we should be clearer on the difference between mounting at a
sub-URL and combining applications in a single WSGI container.  The
Application Dispatching doc is written for the latter.

-Ron


> 2011/7/22 Manel Villar <manelvf@gmail.com>
>>
>> After looking your link and
>> 
http://librelist.com/browser//flask/2011/2/23/soaplib-with-flask/#be4f113dea07ce4e02911c217e1f21ba
>>
>> this is my code:
>>
>> from nas_backend import app
>> from nas_backend import app as backend
>>
>>
>> if __name__ == '__main__':
>>     backend.wsgi_app = DispatcherMiddleware(app.wsgi_app, {
>>       '/nasbackend': backend.wsgi_app
>>       })
>>     backend.run(debug=True, host="0.0.0.0")
>>
>> and it fails (maximum recursion)
>>
>> I only use one application since I only want the mount point (other mount
>> points are used for other non-flask apps in production).
>>
>>
>> 2011/7/22 Daniel , Dao Quang Minh <dqminh89@gmail.com>
>>>
>>> You should use DispatcherMiddleware to declare nasbackend as the prefix
>>> http://flask.pocoo.org/docs/patterns/appdispatch/#combining-applications
>>> Cheers,
>>> Daniel, Dao Quang Minh
>>>
>>> On Fri, Jul 22, 2011 at 9:00 PM, Manel Villar <manelvf@gmail.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have an application running on Cherokee Server on
>>>> domain.com/nasbackend/login, but when I redirect using url_for, I get the
>>>> url domain.com/login . How can I declare a mount point for the app?
>>>>
>>>> Thanks,
>>>>
>>>>
>>>> --
>>>> Manel Villar
>>>> Cerca,74 1ºD
>>>> 15365 Cariño
>>>> A Coruña (Spain)
>>>> Tel: (+34) 636863621
>>>> manelvf@gmail.com
>>>>
>>>> "Ars longa, vita brevis"
>>>
>>
>>
>>
>> --
>> Manel Villar
>> Cerca,74 1ºD
>> 15365 Cariño
>> A Coruña (Spain)
>> Tel: (+34) 636863621
>> manelvf@gmail.com
>>
>> "Ars longa, vita brevis"
>
>
>
> --
> Manel Villar
> Cerca,74 1ºD
> 15365 Cariño
> A Coruña (Spain)
> Tel: (+34) 636863621
> manelvf@gmail.com
>
> "Ars longa, vita brevis"
>

Re: [flask] Application mount point

From:
Armin Ronacher
Date:
2011-07-23 @ 16:06
Hi,

I think we could resolve a whole bunch of issues by making it possible
to run a Flask application from the command line with this:

$ python -mflask.server yourapplication

What would that do?  If would attempt to import yourapplication and then
looks for an object called "app".  If it finds that it uses that,
otherwise you would have to do (yourapplication:application) or
something.  Then it runs that with the development server.

What would that solve?

First of all it would no longer require the if __name__ main thing,
secondly it would solve the double importing problems we commonly see as
well as the fact that modules work different to applications.  Lastly
the application object would no longer have to be a Flask application
object but just any WSGI application object.


Regards,
Armin

Re: [flask] Application mount point

From:
Simon Sapin
Date:
2011-07-23 @ 16:11
Le 23/07/2011 18:06, Armin Ronacher a écrit :
> Hi,
>
> I think we could resolve a whole bunch of issues by making it possible
> to run a Flask application from the command line with this:
>
> $ python -mflask.server yourapplication

Hi,

Would this script accept options for the .run() method? I’m thinking 
mostly of having debug mode off in the application code, but turning it 
on from the command line to start a dev server.

Regards,
-- 
Simon Sapin

Re: [flask] Application mount point

From:
Armin Ronacher
Date:
2011-07-23 @ 16:13
Hi,

On 7/23/11 6:11 PM, Simon Sapin wrote:
> Would this script accept options for the .run() method? I’m thinking 
> mostly of having debug mode off in the application code, but turning it 
> on from the command line to start a dev server.
Probably what's available to werkzeug.serving.run_simple but nothing
Flask specific like the debug flag.


Regards,
Armin

Re: [flask] Application mount point

From:
Ron DuPlain
Date:
2011-07-23 @ 16:11
On Sat, Jul 23, 2011 at 12:06 PM, Armin Ronacher
<armin.ronacher@active-4.com> wrote:
> I think we could resolve a whole bunch of issues by making it possible
> to run a Flask application from the command line with this:
>
> $ python -mflask.server yourapplication
>
> What would that do?  If would attempt to import yourapplication and then
> looks for an object called "app".  If it finds that it uses that,
> otherwise you would have to do (yourapplication:application) or
> something.  Then it runs that with the development server.
>
> What would that solve?
>
> First of all it would no longer require the if __name__ main thing,
> secondly it would solve the double importing problems we commonly see as
> well as the fact that modules work different to applications.  Lastly
> the application object would no longer have to be a Flask application
> object but just any WSGI application object.

Your approach sounds identical to gunicorn.
http://gunicorn.org/

Would gunicorn itself provide what you propose?

-Ron

Re: [flask] Application mount point

From:
Armin Ronacher
Date:
2011-07-23 @ 16:18
Hi,

On 7/23/11 6:11 PM, Ron DuPlain wrote:
> Would gunicorn itself provide what you propose?
Well.  gunicorn is a proper server, so that's obviously something we
could advertise as a good idea.  Just not sure how well gunicorn works
as a general development server as I never used it.  Might be worth
investigating.  Generally though I like the idea of having a builtin
server that the docs refer to because it has the general advantage that
it's something under our control we can tune for a better development
experience.


Regards,
Armin

Re: [flask] Application mount point

From:
Ron DuPlain
Date:
2011-07-23 @ 16:31
On Sat, Jul 23, 2011 at 12:18 PM, Armin Ronacher
<armin.ronacher@active-4.com> wrote:
> On 7/23/11 6:11 PM, Ron DuPlain wrote:
>> Would gunicorn itself provide what you propose?
> Well.  gunicorn is a proper server, so that's obviously something we
> could advertise as a good idea.  Just not sure how well gunicorn works
> as a general development server as I never used it.  Might be worth
> investigating.  Generally though I like the idea of having a builtin
> server that the docs refer to because it has the general advantage that
> it's something under our control we can tune for a better development
> experience.

A built-in development server would be great, and I'd like to see the
gunicorn command-line interface used here where appropriate.  I opened
a new issue and will make a first pass at building this:

https://github.com/mitsuhiko/flask/issues/283

-Ron