Gunicorn对Nginx的错误处理请求

时间:2017-05-21 06:50:54

标签: python nginx flask gunicorn

使用以下命令运行带有gunicorn的Flask应用程序时:

gunicorn --bind 127.0.0.1:8000 myapp:app

将浏览器设置为www.mayapp.com后,我收到以下错误

[ERROR] Error handling request /
Traceback (most recent call last):
  File "/me/.virtualenvs/myapp/lib/python3.5/site-packages/gunicorn/workers/sync.py", line 130, in handle
    self.handle_request(listener, req, client, addr)
  File "/me/.virtualenvs/myapp/lib/python3.5/site-packages/gunicorn/workers/sync.py", line 171, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
TypeError: app() takes from 0 to 1 positional arguments but 2 were given

对于我正在使用的路线:

@app.route("/")
def index():
    return render_template('myapp/index.html')

知道可能出现什么问题吗?

1 个答案:

答案 0 :(得分:0)

问题出在我用于ansible部署脚本的python路径中。应用程序在更正后工作正常

例如

wsgi_env_vars: {
    PYTHONPATH: '${PYTHONPATH}:{{ app_dir }}',