By dter
After following this tutorial to set up flask on nginx and uwsgi (https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-14-04) on Ubuntu 14.04, I managed to get the simple app to work, however when I replace my app with it (with the same name), I’m getting an internal server error. At first this was due to the modules, but this persisted after installing all required modules.
Logging uwsgi it says “no python application found, check your startup logs for errors”.
My python file (portal.py):
app = Flask(__name__, static_folder='static', static_url_path='/static')
app.secret_key = 'askaj3432sd'
app.config.update(
DEBUG=True,
PROPAGATE_EXCEPTIONS=True)
if __name__ == "__main__":
app.run(threaded=True, host='0.0.0.0')
My wsgi.py:
from portal import app
if __name__ == "__main__":
app.run()
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This question was answered by @centolaecebola:
try changing
from portal import appto
from portal import app as application
It’s because uWSGI needs to know the name of the wsgi app instance variable inside wsgi.py.
uWSGI looks for an instance named application by default
https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html#the-first-wsgi-application
You can also configure uWSGI to use an instance named app how you had it originally:
https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html#deploying-flask
I too would like to understand how this worked? I had the exact same issue, added the ‘as application’ and didn’t change anything else and it worked. Anyone have an explanation as to why this works?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.