I am trying to deploy a simple web app that I have built using Python and Flask.
My app has the following structure:
/var/www/watchgallery/
+ app
+ __init__.py
+ views.py
+ templates
+ flask #virtual environment for Flask
+ run.py #script I used in my machine to start the development Flask server
+ watchgallery_nginx.conf
+ watchgallery_uwsgi.ini
+ watchgallery_uwsgi.sock
For this purpose of deploying, I am following this link: http://vladikk.com/2013/09/12/serving-flask-with-nginx-on-ubuntu/
In this tutorial, the Flask app consists of only a hello.py
file. The way he configures his uwsgi file is like this (/var/www/demoapp/demoapp_uwsgi.ini):
[uwsgi]
#application's base folder
base = /var/www/demoapp
#python module to import
app = hello
module = %(app)
home = %(base)/venv
pythonpath = %(base)
#socket file's location
socket = /var/www/demoapp/%n.sock
#permissions for the socket file
chmod-socket = 666
#the variable that holds a flask application inside the module imported at line #6
callable = app
#location of log files
logto = /var/log/uwsgi/%n.log
I have tried to apply the same logic to my uwsgi.ini
file, but I am doing something wrong. This is how my file looks like:
[uwsgi]
#application's base folder
base = /var/www/watchgallery
#python module to import
app = run
module = %(app)
home = %(base)/flask
pythonpath = %(base)
#socket file's location
socket = /var/www/watchgallery/%n.sock
#permissions for the socket file
chmod-socket = 666
#the variable that holds a flask application inside the module imported at line #6
callable = app
When I am developing my app in my local machine, I run this command to start de the server: ./run.py
.
This is my run.py
file:
#!flask/bin/python
from app import app
app.run(debug = False)
Now, my question is: how should my uwsgi.ini file look like given that my Flask app consists of more than a single file?