|
Here is my directory structure:
-/path/to/folder/run.py -|app -|__init__.py -|views.py -|templates -|static
Contents of/path/to/folder/run.py
if __name__ == ‘__main__‘: from app import app #app.run(debug = True) app.run()
Contents of/path/to/folder/app/__init__.py
ImportOsFromFlaskImport FlaskFromFlask.Ext.SQLAlchemyImport SQLAlchemyFromFlask.Ext.LoginImport Loginmanager#from Flaskext.babel Import BabelFromConfigImportBasedirapp= Flask(__name__)App.Config.From_object(' Config ')#app. Config.from_pyfile (' babel.cfg ')Db= SQLAlchemy(App)Login_manager= Loginmanager()Login_manager.Setup_app(App)Login_manager.Login_view= ' Login 'Login_manager.Login_message=U"Please log on to access this page."FromAppImportViews*** OperationalMODE:Preforking***Unable to find"Application"CallableInchFile/Path/To/Folder/Run.Pyunable to load App0 (Mountpoint=‘‘) (CallableNotFoundOr ImportError)***No app Loaded.GoingInchFull dynamic mode****** Uwsgi is running in***spawned uwsgi worker 1 (pid: 26972< Span class= "pun" >, Cores: 1 spawned uwsgi worker 2 (pid: 26973 Cores: 1) Python flask Uwsgi
| ShareImprove this question |
Edited Dec ' at 18:02Akira 4,662 |
Asked ' at 23:30Tampa9,169126 209 |
|
|
Add a Comment |
2 Answersactiveoldestvotes
| Up vote13down voteaccepted |
Uwsgi doesn ' t load your app as __main__ , so it never would find The app (since, loaded when the app is run as name __main__ ). Thus, need to import it outside of the if __name__ = = "__main__": block.
Really simple change:
from app import Appif __name__ = = "__main__" : App.< Span class= "PLN" >run ()
Now you can run the app directly with python run.py or run it through Uwsgi the "the" I |
Flask and uwsgi-unable to load app 0 (mountpoint= ") (callable not found or import error)