librelist archives

« back to archive

Uwsgi config

Uwsgi config

From:
Jair Gaxiola
Date:
2011-07-05 @ 00:09
Hi,

I try configure flask on nginx, but return the error "uWSGI Error wsgi
application not found" my vhost

server {
    listen       80;
    server_name  flask.local;

    location / {
      try_files $uri @flasks;
    }

    location @flasks {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:9001;
      }

    access_log  /Applications/MNPP/logs/nginx/flask.local.access.log;
    error_log  /Applications/MNPP/logs/nginx/flask.local.error.log;

}

and my app

from flask import Flask
app = Flask(__name__)
print "dentro"
@app.route('/')
def hello_world():
    return "Hello World flask!"

if __name__ == '__main__':
    app.run()


Any suggestions?

Thanks
-- 
SIN ETIQUETAS.[ PUNTO ]
http://flavors.me/jyr
http://pythoncocoa.com
http://opentumblr.com

Re: [flask] Uwsgi config

From:
James Thornton
Date:
2011-07-05 @ 06:00
Try something like this...

    upstream flask {
    	     server 127.0.0.1:9001;
    }

    server {
        listen       80;
        server_name  _;

        location / {
            proxy_pass http://flask;   	
        }
  }


On Mon, Jul 4, 2011 at 7:09 PM, Jair Gaxiola <jyr.gaxiola@gmail.com> wrote:
> Hi,
>
> I try configure flask on nginx, but return the error "uWSGI Error wsgi
> application not found" my vhost
>
> server {
>    listen       80;
>    server_name  flask.local;
>
>    location / {
>      try_files $uri @flasks;
>    }
>
>    location @flasks {
>        include uwsgi_params;
>        uwsgi_pass 127.0.0.1:9001;
>      }
>
>    access_log  /Applications/MNPP/logs/nginx/flask.local.access.log;
>    error_log  /Applications/MNPP/logs/nginx/flask.local.error.log;
>
> }
>
> and my app
>
> from flask import Flask
> app = Flask(__name__)
> print "dentro"
> @app.route('/')
> def hello_world():
>    return "Hello World flask!"
>
> if __name__ == '__main__':
>    app.run()
>
>
> Any suggestions?
>
> Thanks
> --
> SIN ETIQUETAS.[ PUNTO ]
> http://flavors.me/jyr
> http://pythoncocoa.com
> http://opentumblr.com
>



-- 
Latest Blog: http://jamesthornton.com/blog/how-to-get-to-genius

Re: [flask] Uwsgi config

From:
Roberto De Ioris
Date:
2011-07-05 @ 05:32
> Hi,
>
> I try configure flask on nginx, but return the error "uWSGI Error wsgi
> application not found" my vhost
>
> server {
>     listen       80;
>     server_name  flask.local;
>
>     location / {
>       try_files $uri @flasks;
>     }
>
>     location @flasks {
>         include uwsgi_params;
>         uwsgi_pass 127.0.0.1:9001;
>       }
>
>     access_log  /Applications/MNPP/logs/nginx/flask.local.access.log;
>     error_log  /Applications/MNPP/logs/nginx/flask.local.error.log;
>
> }
>
> and my app
>
> from flask import Flask
> app = Flask(__name__)
> print "dentro"
> @app.route('/')
> def hello_world():
>     return "Hello World flask!"
>
> if __name__ == '__main__':
>     app.run()
>
>
> Any suggestions?
>
>

You should report uWSGI logs and command line/config file parameters.

Your nginx configuration looks good, so you must have done some mistake in
uWSGI config
-- 
Roberto De Ioris
http://unbit.it

Re: [flask] Uwsgi config

From:
Jair Gaxiola
Date:
2011-07-05 @ 05:43
On Tue, Jul 5, 2011 at 12:32 AM, Roberto De Ioris <roberto@unbit.it> wrote:
>
>> Hi,
>>
>> I try configure flask on nginx, but return the error "uWSGI Error wsgi
>> application not found" my vhost
>>
>> server {
>>     listen       80;
>>     server_name  flask.local;
>>
>>     location / {
>>       try_files $uri @flasks;
>>     }
>>
>>     location @flasks {
>>         include uwsgi_params;
>>         uwsgi_pass 127.0.0.1:9001;
>>       }
>>
>>     access_log  /Applications/MNPP/logs/nginx/flask.local.access.log;
>>     error_log  /Applications/MNPP/logs/nginx/flask.local.error.log;
>>
>> }
>>
>> and my app
>>
>> from flask import Flask
>> app = Flask(__name__)
>> print "dentro"
>> @app.route('/')
>> def hello_world():
>>     return "Hello World flask!"
>>
>> if __name__ == '__main__':
>>     app.run()
>>
>>
>> Any suggestions?
>>
>>
>
> You should report uWSGI logs and command line/config file parameters.
>
> Your nginx configuration looks good, so you must have done some mistake in
> uWSGI config

Added two lines to my code:

def application(environ, start_response):
  return app(environ, start_response)

My complete code:

https://gist.github.com/1064160


-- 
SIN ETIQUETAS.[ PUNTO ]
http://flavors.me/jyr
http://pythoncocoa.com
http://opentumblr.com

Re: [flask] Uwsgi config

From:
Roberto De Ioris
Date:
2011-07-05 @ 05:49
> On Tue, Jul 5, 2011 at 12:32 AM, Roberto De Ioris <roberto@unbit.it>
> wrote:
>>
>>> Hi,
>>>
>>> I try configure flask on nginx, but return the error "uWSGI Error wsgi
>>> application not found" my vhost
>>>
>>> server {
>>>     listen       80;
>>>     server_name  flask.local;
>>>
>>>     location / {
>>>       try_files $uri @flasks;
>>>     }
>>>
>>>     location @flasks {
>>>         include uwsgi_params;
>>>         uwsgi_pass 127.0.0.1:9001;
>>>       }
>>>
>>>     access_log
>>>  /Applications/MNPP/logs/nginx/flask.local.access.log;
>>>     error_log  /Applications/MNPP/logs/nginx/flask.local.error.log;
>>>
>>> }
>>>
>>> and my app
>>>
>>> from flask import Flask
>>> app = Flask(__name__)
>>> print "dentro"
>>> @app.route('/')
>>> def hello_world():
>>>     return "Hello World flask!"
>>>
>>> if __name__ == '__main__':
>>>     app.run()
>>>
>>>
>>> Any suggestions?
>>>
>>>
>>
>> You should report uWSGI logs and command line/config file parameters.
>>
>> Your nginx configuration looks good, so you must have done some mistake
>> in
>> uWSGI config
>
> Added two lines to my code:
>
> def application(environ, start_response):
>   return app(environ, start_response)
>
> My complete code:
>
> https://gist.github.com/1064160


Ugly :)

You can do

application = app

in your code

or force uWSGI to use "app" as the callable (instead of "application") with:

--callable app

or

http://projects.unbit.it/uwsgi/wiki/Example#Flaskdeploy


-- 
Roberto De Ioris
http://unbit.it

Re: [flask] Uwsgi config

From:
Jair Gaxiola
Date:
2011-07-05 @ 06:05
On Tue, Jul 5, 2011 at 12:49 AM, Roberto De Ioris <roberto@unbit.it> wrote:
>
>> On Tue, Jul 5, 2011 at 12:32 AM, Roberto De Ioris <roberto@unbit.it>
>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I try configure flask on nginx, but return the error "uWSGI Error wsgi
>>>> application not found" my vhost
>>>>
>>>> server {
>>>>     listen       80;
>>>>     server_name  flask.local;
>>>>
>>>>     location / {
>>>>       try_files $uri @flasks;
>>>>     }
>>>>
>>>>     location @flasks {
>>>>         include uwsgi_params;
>>>>         uwsgi_pass 127.0.0.1:9001;
>>>>       }
>>>>
>>>>     access_log
>>>>  /Applications/MNPP/logs/nginx/flask.local.access.log;
>>>>     error_log  /Applications/MNPP/logs/nginx/flask.local.error.log;
>>>>
>>>> }
>>>>
>>>> and my app
>>>>
>>>> from flask import Flask
>>>> app = Flask(__name__)
>>>> print "dentro"
>>>> @app.route('/')
>>>> def hello_world():
>>>>     return "Hello World flask!"
>>>>
>>>> if __name__ == '__main__':
>>>>     app.run()
>>>>
>>>>
>>>> Any suggestions?
>>>>
>>>>
>>>
>>> You should report uWSGI logs and command line/config file parameters.
>>>
>>> Your nginx configuration looks good, so you must have done some mistake
>>> in
>>> uWSGI config
>>
>> Added two lines to my code:
>>
>> def application(environ, start_response):
>>   return app(environ, start_response)
>>
>> My complete code:
>>
>> https://gist.github.com/1064160
>
>
> Ugly :)
>
> You can do
>
> application = app
>
> in your code
>
> or force uWSGI to use "app" as the callable (instead of "application") with:
>
> --callable app
>
> or
>
> http://projects.unbit.it/uwsgi/wiki/Example#Flaskdeploy
>

Ok, my plist file  in https://gist.github.com/1064322

Thanks


-- 
SIN ETIQUETAS.[ PUNTO ]
http://flavors.me/jyr
http://pythoncocoa.com
http://opentumblr.com

Re: [flask] Uwsgi config

From:
Roberto De Ioris
Date:
2011-07-05 @ 06:10
> On Tue, Jul 5, 2011 at 12:49 AM, Roberto De Ioris <roberto@unbit.it>
> wrote:
>>
>>> On Tue, Jul 5, 2011 at 12:32 AM, Roberto De Ioris <roberto@unbit.it>
>>> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I try configure flask on nginx, but return the error "uWSGI Error
>>>>> wsgi
>>>>> application not found" my vhost
>>>>>
>>>>> server {
>>>>>     listen       80;
>>>>>     server_name  flask.local;
>>>>>
>>>>>     location / {
>>>>>       try_files $uri @flasks;
>>>>>     }
>>>>>
>>>>>     location @flasks {
>>>>>         include uwsgi_params;
>>>>>         uwsgi_pass 127.0.0.1:9001;
>>>>>       }
>>>>>
>>>>>     access_log
>>>>>  /Applications/MNPP/logs/nginx/flask.local.access.log;
>>>>>     error_log
>>>>>  /Applications/MNPP/logs/nginx/flask.local.error.log;
>>>>>
>>>>> }
>>>>>
>>>>> and my app
>>>>>
>>>>> from flask import Flask
>>>>> app = Flask(__name__)
>>>>> print "dentro"
>>>>> @app.route('/')
>>>>> def hello_world():
>>>>>     return "Hello World flask!"
>>>>>
>>>>> if __name__ == '__main__':
>>>>>     app.run()
>>>>>
>>>>>
>>>>> Any suggestions?
>>>>>
>>>>>
>>>>
>>>> You should report uWSGI logs and command line/config file parameters.
>>>>
>>>> Your nginx configuration looks good, so you must have done some
>>>> mistake
>>>> in
>>>> uWSGI config
>>>
>>> Added two lines to my code:
>>>
>>> def application(environ, start_response):
>>>   return app(environ, start_response)
>>>
>>> My complete code:
>>>
>>> https://gist.github.com/1064160
>>
>>
>> Ugly :)
>>
>> You can do
>>
>> application = app
>>
>> in your code
>>
>> or force uWSGI to use "app" as the callable (instead of "application")
>> with:
>>
>> --callable app
>>
>> or
>>
>> http://projects.unbit.it/uwsgi/wiki/Example#Flaskdeploy
>>
>
> Ok, my plist file  in https://gist.github.com/1064322
>
> Thanks
>
>

This options are not needed for your setup:

 <string>--vhost</string>
 <string>--no-site</string>
 <string>--pythonpath</string>
 <string>/Applications/MNPP/Library/python26/lib/python2.6/lib-dynload/</string>
 <string>--pythonpath</string>
 <string>/Applications/MNPP/Library/python26/lib/python2.6/site-packages/</string>

and change

<string>--callable</string>
<string>app</string>

to

<string>--module</string>
<string>myapp:app</string>


where myapp is the name of your flask app (without .py extension) in the
/Applications/MNPP/htdocs/ directory



-- 
Roberto De Ioris
http://unbit.it