使用以下命令运行带有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')
知道可能出现什么问题吗?
答案 0 :(得分:0)
问题出在我用于ansible部署脚本的python路径中。应用程序在更正后工作正常
例如
wsgi_env_vars: {
PYTHONPATH: '${PYTHONPATH}:{{ app_dir }}',