Search code examples
windowsfalconframeworkwaitress

Falcon (Waitress) tutorial module object is not callable


So I am going through Falcon tutorial on windows 10 with venv

falcon==1.4.1
waitress==1.1.0

User guide went well but it was served with:

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

The tutorial works with two files for now:

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 initiated with:

waitress-serve --port=8000 look:app

request made with:

http localhost:8000/images

error response:

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

Any ideas / inputs how to overcome this ?


Solution

  • Found an issue, the tutorial in falcon framework got it wrong with the waitress command.

    Here is the related github issue.

    The command should be:

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