Gunicorn 内部服务器错误
Gunicorn Internal Server Error
我正在使用 Flask 应用程序设置 Gunicorn。我有以下文件结构:
Flask/
run.py
myapp/
__init__.py
views/
homepage/
__init__.py
homepage.py
login/
__init__.py
login.py
blog/
__init__.py
blog.py
run.py
文件在 Flask/myapp/__init__.py
中导入应用程序实例,运行 就像这样:
from myapp import app
def run():
app.run()
使用命令行,我 运行 gunicorn run:run
网站启动。我访问该网站并收到一个内部服务器错误,说明如下:
[2015-09-14 19:00:41 +0100] [35529] [ERROR] Error handling request
Traceback (most recent call last):
File "/Users/pavsidhu/.virtualenvs/environment/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 130, in handle
self.handle_request(listener, req, client, addr)
File "/Users/pavsidhu/.virtualenvs/environment/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 171, in handle_request
respiter = self.wsgi(environ, resp.start_response)
TypeError: run() takes no arguments (2 given)
问题是什么?谢谢。
你应该通过 a WSGI callable to gunicorn
。事实证明 app
是一个,但您的 run
函数不是。
所以,而不是 运行宁 gunicorn run:run
,运行:gunicorn run:app
。
我正在使用 Flask 应用程序设置 Gunicorn。我有以下文件结构:
Flask/
run.py
myapp/
__init__.py
views/
homepage/
__init__.py
homepage.py
login/
__init__.py
login.py
blog/
__init__.py
blog.py
run.py
文件在 Flask/myapp/__init__.py
中导入应用程序实例,运行 就像这样:
from myapp import app
def run():
app.run()
使用命令行,我 运行 gunicorn run:run
网站启动。我访问该网站并收到一个内部服务器错误,说明如下:
[2015-09-14 19:00:41 +0100] [35529] [ERROR] Error handling request
Traceback (most recent call last):
File "/Users/pavsidhu/.virtualenvs/environment/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 130, in handle
self.handle_request(listener, req, client, addr)
File "/Users/pavsidhu/.virtualenvs/environment/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 171, in handle_request
respiter = self.wsgi(environ, resp.start_response)
TypeError: run() takes no arguments (2 given)
问题是什么?谢谢。
你应该通过 a WSGI callable to gunicorn
。事实证明 app
是一个,但您的 run
函数不是。
所以,而不是 运行宁 gunicorn run:run
,运行:gunicorn run:app
。