无法调用web.py应用程序:wsgifunc()失败

时间:2016-10-27 14:10:46

标签: python mod-wsgi wsgi web.py

我正在尝试在我的apache服务器上启动web.py应用程序。 但是当我尝试调用任何REST服务时,我收到了一个wsgi错误。 在我的代码下面:

urls = (
  '/publication/(.*)', 'PublicationStats',
  '/author/(.*)', 'AuthorStats',
  '/department/(.*)', 'DepartmentStats'
)
application = web.application(urls, globals()).wsgifunc()
...
if __name__ == "__main__":
  #web.config.debug = True
  application.run()

当我尝试调用我的REST api /author/Smith, John时,我的Apache服务器会生成一个关于wsgi的奇怪错误:

[Thu Oct 27 15:54:28.614753 2016] [cgi:error] [pid 2979] [client 130.104.xxx.xxx:62194] AH01215: Traceback (most recent call last):, referer: http://test.dial.uclouvain.be/swagger/
[Thu Oct 27 15:54:28.614841 2016] [cgi:error] [pid 2979] [client 130.104.xxx.xxx:62194] AH01215:   File "/var/www/html/api/dilbert/api.py", line 377, in <module>, referer: http://localhost/swagger/
[Thu Oct 27 15:54:28.614856 2016] [cgi:error] [pid 2979] [client 130.104.xxx.xxx:62194] AH01215:     application.run(), referer: http://localhost/swagger/
[Thu Oct 27 15:54:28.614877 2016] [cgi:error] [pid 2979] [client 130.104.xxx.xxx:62194] AH01215: AttributeError: 'function' object has no attribute 'run', referer: http://localhost/swagger/
[Thu Oct 27 15:54:28.636844 2016] [cgi:error] [pid 2979] [client 130.104.xxx.xxx:62194] End of script output before headers: api.py, referer: http://localhost/swagger/

如果我只使用“web.application(urls, globals())”,它就有效。但我需要使用wsgifunc,因为我需要访问web.ctx.env variable

mod_wsgi安装在Apache上。看起来很好......我希望 谢谢你的帮助

雷诺

1 个答案:

答案 0 :(得分:0)

基于@sytech建议,我更新了我的apache配置:

?-