0
我命名的,而不是通常的app.py
我的初始化文件__main__.py
,因爲我想與如何在__main__.py中使用gunicorn?
$ python flask_api/
但現在運行它,當我試圖用Gunicorn使用它,它看起來這名限制:
$ gunicorn flask_api:app
[2017-07-28 22:40:33 +0300] [15488] [INFO] Starting gunicorn 19.7.1
[2017-07-28 22:40:33 +0300] [15488] [INFO] Listening at: http://127.0.0.1:8000 (15488)
[2017-07-28 22:40:33 +0300] [15488] [INFO] Using worker: sync
[2017-07-28 22:40:33 +0300] [15491] [INFO] Booting worker with pid: 15491
Failed to find application: 'flask_api'
[2017-07-28 22:40:33 +0300] [15491] [INFO] Worker exiting (pid: 15491)
[2017-07-28 22:40:33 +0300] [15488] [INFO] Shutting down: Master
[2017-07-28 22:40:33 +0300] [15488] [INFO] Reason: App failed to load.
我也試着用另一種方式啓動它:
$ cd flask_api/
$ gunicorn __main__:app
[2017-07-28 22:42:06 +0300] [15766] [INFO] Starting gunicorn 19.7.1
[2017-07-28 22:42:06 +0300] [15766] [INFO] Listening at: http://127.0.0.1:8000 (15766)
[2017-07-28 22:42:06 +0300] [15766] [INFO] Using worker: sync
[2017-07-28 22:42:06 +0300] [15769] [INFO] Booting worker with pid: 15769
Failed to find application: '__main__'
[2017-07-28 22:42:06 +0300] [15769] [INFO] Worker exiting (pid: 15769)
[2017-07-28 22:42:06 +0300] [15766] [INFO] Shutting down: Master
[2017-07-28 22:42:06 +0300] [15766] [INFO] Reason: App failed to load.
有什麼問題和浩我可以修復它嗎?
順便說一句,這裏是我flask_api/
結構:
flask_api/
├── blueprints
│ ├── add_methods.py
│ └── get_methods.py
├── config.py
├── __main__.py
└── README.md
感謝您的回答,但它仍然無效。導入有誤: 'from config import BaseConfig ImportError:No module named'config'' –
謝謝你花費我的時間:)我已經添加了這兩個文件'__init __。py'(它們是空白的)和它仍然有相同的錯誤:( –