I get the below error when I try and start Flask using uWSGI. Here is how I start:
> # cd ..
> root@localhost:# uwsgi --socket 127.0.0.1:6000 --fi
uWSGI doesn't load your app as __main__
, so it never will find the app
(since that only gets loaded when the app is run as name __main__
). Thus, you need to import it outside of the if __name__ == "__main__":
block.
Really simple change:
from app import app as application # for example, should be app
if __name__ == "__main__":
application.run()
Now you can run the app directly with python run.py
or run it through uWSGI the way you have it.
NOTE: if you set --callable myapp
, you'd need to change it from as application
to myapp
(by default uwsgi
expects application