【问题标题】:Gunicorn on Nginx error handing requestGunicorn on Nginx 错误处理请求
【发布时间】:2017-05-26 14:52:41
【问题描述】:

当我使用以下命令运行带有 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')

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

【问题讨论】:

    标签: python nginx flask gunicorn


    【解决方案1】:

    问题出在我用于 ansible 部署脚本的 python 路径中。更正后应用正常运行

    例如

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

    【讨论】:

      猜你喜欢
      • 2014-02-19
      • 1970-01-01
      • 2015-03-31
      • 1970-01-01
      • 2015-06-17
      • 1970-01-01
      • 1970-01-01
      • 2021-02-07
      • 2020-08-26
      相关资源
      最近更新 更多