2017-09-01 74 views
0

我的Heroku应用程序运行到应用程序错误与以下日志:为什么heroku无法找到python/flask模块或应用程序?

Starting process with command `gunicorn run:app` 

Failed to find application: run 

这里是我的Procfile

web: gunicorn run:flask_app 

run.py文件

从应用进口create_app,DB 从应用程序。 auth.models import用户

if __name__ == '__main__': 
    flask_app = create_app('prod') 
    with flask_app.app_context(): 
     db.create_all() 
     if not User.query.filter_by(user_name='harry').first(): 
      User.create_user(user='harry', email='[email protected]', password='secret') 
    flask_app.run() 

回答

0

由于Gunicorn正在调用您的脚本,因此您的main-method没有执行(AFAIK),您并未执行它作为主文件。尝试将flask_app从主要方法移至文件顶部,以便Gunicorn在导入run.py时实际可以找到它!

+0

尝试Noshii,不工作... – Hara