运行 一个简单的猎鹰应用程序
Running a Simple Falcon App
我有一个直接来自入门示例的简单 falcon 应用程序
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.
我在这里做错了什么?
不知道是打错了还是误会了,但是你应该这样开始申请:
gunicorn manage:api
但不是gunicorn manage:app
manage:api
选项指示调用 manage.py 模块中定义的 api
对象。否则,您需要在代码中将 api
变量重命名为 app
。
然后您可以通过访问以下 url:
来检查应用程序是否为 运行
http://localhost:8000/quote
默认端口应该8000
但是你需要在gunicorn启动时检查它。它应该是这样的:
[INFO] Listening at: http://127.0.0.1:8000
我有一个直接来自入门示例的简单 falcon 应用程序
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.
我在这里做错了什么?
不知道是打错了还是误会了,但是你应该这样开始申请:
gunicorn manage:api
但不是gunicorn manage:app
manage:api
选项指示调用 manage.py 模块中定义的 api
对象。否则,您需要在代码中将 api
变量重命名为 app
。
然后您可以通过访问以下 url:
来检查应用程序是否为 运行http://localhost:8000/quote
默认端口应该8000
但是你需要在gunicorn启动时检查它。它应该是这样的:
[INFO] Listening at: http://127.0.0.1:8000