Reputation: 8041
I'm at a loss here...
I'm trying to use uwsgi to run my flask app. Using the example at WSGI Quick Start I get it to run.
For development (restserver.py):
from api import app
if __name__ == '__main__':
app.run(debug=True, port=8080)
How would I start the uwsgi server with this?
I have tried this (restserver.fcgi):
#!/usr/bin/python
from flup.server.fcgi import WSGIServer
from api import app
if __name__ == '__main__':
WSGIServer(app, bindAddress='/var/run/fcgi.sock').run()
but when reading more I see that uwsgi want's to call the method application
by default. I can change that of course but I don't have and application
method so when running:
/usr/local/bin/uwsgi --http :9090 --wsgi-file restserver.fcgi
I get the following message in the start log:
unable to find "application" callable in file restserver.fcgi
Upvotes: 3
Views: 1097
Reputation: 6162
All you need is to change start command to
/usr/local/bin/uwsgi --http :9090 --wsgi-file restserver.fcgi --callable app
or change the way you import your flask application in restserver.fcgi
to
#!/usr/bin/python
from flup.server.fcgi import WSGIServer
from api import app as application
if __name__ == '__main__':
WSGIServer(application, bindAddress='/var/run/fcgi.sock').run()
Docs on using uWSGI with Flask
PS: Actually your flask app
is WSGI application.
Upvotes: 3