Gunicorn failed to load Flask application

后端 未结 1 1379
旧巷少年郎
旧巷少年郎 2021-02-01 20:03

I have a Flask app I am trying to serve via Gunicorn.

I am using virtualenv and python3. If I activate my venv cd to my app base dir then run:

gunicorn m         


        
相关标签:
1条回答
  • 2021-02-01 20:34

    You're pointing gunicorn at mysite:app, which is equivalent to from mysite import app. However, there is no app object in the top (__init__.py) level import of mysite. Tell gunicorn to call the factory.

    gunicorn "mysite:create_app()"
    

    You can pass arguments to the call as well.

    gunicorn "mysite:create_app('production')"
    

    Internally, this is equivalent to:

    from mysite import create_app
    app = create_app('production')
    

    Alternatively, you can use a separate file that does the setup. In your case, you already initialized an app in manage.py.

    gunicorn manage:app
    
    0 讨论(0)
提交回复
热议问题