【发布时间】:2016-10-27 14:10:46
【问题描述】:
我正在尝试在我的 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()
当我尝试像/author/Smith, John 一样调用我的 REST api 时,我的 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 上安装得很好。它似乎工作正常......我希望。
感谢您的帮助
雷诺
【问题讨论】:
-
对我来说,这听起来像是没有为您的脚本使用适当的处理程序。在您的
.htaccess文件中,您是否有此脚本的SetHandler wsgi-script?
标签: python mod-wsgi wsgi web.py