2017-09-01 76 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