运行webpy Hello World示例时的问题

0 投票
1 回答
765 浏览
提问于 2025-04-16 11:46

我正在尝试从官方网站运行一个“你好,世界”的示例:

import web

urls = ('/.*', 'index')
app = web.application(urls, globals())

class index:  
    def GET(self):   
        return 'Hello,world......'

if __name__ == "__main__":  
    web.wsgi.runwsgi = lambda func, addr = None: web.wsgi.runfcgi(func, addr)  
    app.run()  

当我运行它时,出现了这个错误:

 File "E:\Text-1.py", line 15, in <module>
    app.run()
  File "D:\tool\EPD\lib\site-packages\web\application.py", line 316, in run
    return wsgi.runwsgi(self.wsgifunc(*middleware))
  File "E:\Text-1.py", line 14, in <lambda>
    web.wsgi.runwsgi = lambda func, addr = None: web.wsgi.runfcgi(func, addr)
  File "D:\tool\EPD\lib\site-packages\web\wsgi.py", line 17, in runfcgi
    return flups.WSGIServer(func, multiplexed=True, bindAddress=addr).run()
  File "D:\tool\EPD\lib\site-packages\flup-1.0.3.dev_20110111-py2.6.egg\flup\server\fcgi.py", line 112, in run
    sock = self._setupSocket()
  File "D:\tool\EPD\lib\site-packages\flup-1.0.3.dev_20110111-py2.6.egg\flup\server\fcgi_base.py", line 1020, in _setupSocket
    'If you want FCGI, please create an external FCGI server '
ValueError: If you want FCGI, please create an external FCGI server by providing a valid bindAddress. If you want CGI, please force CGI operation. Use FCGI_FORCE_CGI=Y environment or forceCGI parameter.

这是什么问题呢?

1 个回答

1

我不知道这样做是否有帮助,但我只是把这一行注释掉了:

web.wsgi.runwsgi = lambda func, addr = None: web.wsgi.runfcgi(func, addr)

这样运行就没问题了。

撰写回答