我无法从命令行运行web.py
问题描述:
我刚刚安装了一个新的virtualenv项目并安装了web.py,创建了一个测试应用程序,以查看事情是否按预期运行,但没有启动并且没有抛出任何错误我无法从命令行运行web.py
林在MacOS塞拉利昂10.12.3
webservice.py
import web
urls = (
'/(.*)', 'hello'
)
class hello:
def GET(self, name):
if not name:
name = 'Kitty'
return 'Hello '+ name
if __name__ == "main":
app = web.application(urls, globals())
app.run()
requirements.txt
appdirs==1.4.0
nose==1.3.7
packaging==16.8
Paste==2.0.3
pyparsing==2.1.10
python-mimeparse==1.6.0
six==1.10.0
web.py==0.38
使用Python 2.7.13
python webservice.py不做任何事
答
您在webservice.py
中有无效的if语句。请将其替换为:
if __name__ == '__main__':
app = web.application(urls, globals())
app.run()
+0
facepalm ....感谢指出显而易见:D –
+0
这是一个愚蠢的错误,但正如你所看到的 - 很难调试:) – ppkt
url =()是否有 –
可能是你在这里粘贴的cmd你运行的? –
“(venv)kn $ python webservice.py”如上所述,但没有任何反应,没有任何错误信息没有任何东西 –