0

I'm trying to run a simple server

from klein import Klein

app = Klein()

@app.route("/")
def hello(request):
    return "Hello World!"

if __name__ == "__main__":
    run("localhost", 8080)

I packaged and uploaded it to AWS Lambda using Zappa, hover i'm getting this after calling the endpoint, any idea why?

"{'message': 'An uncaught exception happened while servicing this request. You can investigate this with the `zappa tail` command.', 'traceback': ['Traceback (most recent call last):\\n', '  File \"/var/task/handler.py\", line 452, in handler\\n    response = Response.from_app(self.wsgi_app, environ)\\n', '  File \"/var/task/werkzeug/wrappers.py\", line 939, in from_app\\n    return cls(*_run_wsgi_app(app, environ, buffered))\\n', '  File \"/var/task/werkzeug/test.py\", line 923, in run_wsgi_app\\n    app_rv = app(environ, start_response)\\n', '  File \"/var/task/zappa/middleware.py\", line 70, in __call__\\n    response = self.application(environ, encode_response)\\n', \"TypeError: 'Klein' object is not callable\\n\"]}"
MtziSam
  • 130
  • 11

1 Answers1

0

It cannot call the object Klein(). You need to add it to the virtualenv in order to import it as only the virtualenv is build and deployed with zappa.

For example, you could create a setup.py script which allows to install your custom code with pip to your virtual environment as described here: https://docs.python.org/3/distutils/setupscript.html

Rene B.
  • 6,557
  • 7
  • 46
  • 72