Falcon (Waitress) 教程模块对象不可调用

Falcon (Waitress) tutorial module object is not callable

所以我正在 windows 10 上使用 venv

学习 Falcon 教程
falcon==1.4.1
waitress==1.1.0

用户指南运行良好,但提供:

httpd = simple_server.make_server('127.0.0.1', 8000, app)
httpd.serve_forever()

本教程目前使用两个文件:

resource.py:

    import json
    import falcon

    class Resource(object):
        def on_get(self, req, resp):
            doc = {
                'images': [
                    {
                        'href': '/images/1eaf6ef1-7f2d-4ecc-a8d5-6e8adba7cc0e.png'
                    }
                ]
            }
            resp.body = json.dumps(doc, ensure_ascii=False)
            resp.status = falcon.HTTP_200

app.py:

import falcon
from .images import Resource
api = application = falcon.API()
images = Resource()
api.add_route('/images', images)

女服务员发起:

waitress-serve --port=8000 look:app

请求:

http localhost:8000/images

错误响应:

ERROR:waitress:Exception when serving /images Traceback (most recent call last): File "c:\users\ivan\dev\py\projects\falcon\look.venv\lib\site-packages\waitress\channel.py", line 338, in service task.service() File "c:\users\ivan\dev\py\projects\falcon\look.venv\lib\site-packages\waitress\task.py", line 169, in service self.execute() File "c:\users\ivan\dev\py\projects\falcon\look.venv\lib\site-packages\waitress\task.py", line 399, in execute app_iter = self.channel.server.application(env, start_response) TypeError: 'module' object is not callable

任何想法/输入如何克服这个问题?

发现一个问题,falcon framework中的教程把waitress命令搞错了

这里是相关的 github issue.

命令应该是:

waitress-serve --port=8000 look.app:api