我有这个代码在我的服务器中创建一个webapp:
import web
urls = (
'/update', 'Update',
)
app = web.application(urls, globals())
class Update:
print "hola"
if __name__=='__main__':
app.run()
当我尝试执行时:
python@ubuntu:~$ python prueba.py 8081
hola
http://0.0.0.0:8081/
Traceback (most recent call last):
File "prueba.py", line 21, in <module>
app.run()
File "/usr/local/lib/python2.6/dist-packages/web/application.py", line 311, in run
return wsgi.runwsgi(self.wsgifunc(*middleware))
File "/usr/local/lib/python2.6/dist-packages/web/wsgi.py", line 54, in runwsgi
return httpserver.runsimple(func, validip(listget(sys.argv, 1, '')))
File "/usr/local/lib/python2.6/dist-packages/web/httpserver.py", line 148, in runsimple
server.start()
File "/usr/local/lib/python2.6/dist-packages/web/wsgiserver/__init__.py", line 1753, in start
raise socket.error(msg)
socket.error: No socket could be created
为什么会这样?
提前谢谢
答案 0 :(得分:3)
错误消息表明它无法在指定端口上创建侦听套接字。检查端口8081上是否已运行服务器。