我是一个简单的猎鹰应用程序直接从入门示例
import falcon
import json
class QuoteResource:
def on_get(self, req, resp):
"""Handles GET requests"""
quote = {
'quote': 'I\'ve always been more interested in the future than in the past.',
'author': 'Grace Hopper'
}
resp.body = json.dumps(quote)
api = falcon.API()
api.add_route('/quote', QuoteResource())
代码位于名为manage.py
当我尝试运行gunicorn manage:app
时
这就是我得到的
2017-06-04 20:47:18 -0700] [2370] [INFO] Starting gunicorn 19.7.1
[2017-06-04 20:47:18 -0700] [2370] [INFO] Listening at: http://127.0.0.1:8000 (2370)
[2017-06-04 20:47:18 -0700] [2370] [INFO] Using worker: sync
[2017-06-04 20:47:18 -0700] [2373] [INFO] Booting worker with pid: 2373
Failed to find application: 'manage'
[2017-06-04 20:47:18 -0700] [2373] [INFO] Worker exiting (pid: 2373)
[2017-06-04 20:47:18 -0700] [2370] [INFO] Shutting down: Master
[2017-06-04 20:47:18 -0700] [2370] [INFO] Reason: App failed to load.
我在这里做错了什么?
答案 0 :(得分:2)
不确定是否是拼写错误或误解,但您应该以这种方式启动应用程序:
gunicorn manage:api
但不是gunicorn manage:app
manage:api
选项告诉您调用manage.py模块中定义的api
对象。否则,您需要在代码中将api
变量重命名为app
。
然后,您可以通过访问以下网址检查该应用程序是否正在运行:
http://localhost:8000/quote
默认情况下,端口应为8000
,但您需要在gunicorn启动时进行检查。它应该是这样的:
[INFO] Listening at: http://127.0.0.1:8000