2015-04-03 48 views
1

我与瓶子的工作,并编写了一个简单的应用程序瓶试图访问套接字由它不允许的方式许可

from bottle import * 

@route("/") 
def index(): 
    return "This is a test." 

run(host="0.0.0.0", port=8080) 

当我运行此我得到一个错误,指出:

Traceback (most recent call last): 
    File "C:\Users\James\Desktop\application.py", line 7, in <module> 
    run(host="0.0.0.0", port=8080) 
    File "C:\Python34\lib\site-packages\bottle.py", line 3117, in run 
    server.run(app) 
    File "C:\Python34\lib\site-packages\bottle.py", line 2771, in run 
    srv = make_server(self.host, self.port, app, server_cls, handler_cls) 
    File "C:\Python34\lib\wsgiref\simple_server.py", line 153, in make_server 
    server = server_class((host, port), handler_class) 
    File "C:\Python34\lib\socketserver.py", line 429, in __init__ 
    self.server_bind() 
    File "C:\Python34\lib\wsgiref\simple_server.py", line 50, in server_bind 
    HTTPServer.server_bind(self) 
    File "C:\Python34\lib\http\server.py", line 133, in server_bind 
    socketserver.TCPServer.server_bind(self) 
    File "C:\Python34\lib\socketserver.py", line 440, in server_bind 
    self.socket.bind(self.server_address) 
OSError: [WinError 10013] An attempt was made to access a socket in a way forbid 
den by its access permissions 

看看其他SO帖子,似乎是我需要通过防火墙允许它。我这样做:

I let Python through the firewall

但错误依然存在,我该怎么做才能解决这个问题?

+0

你尝试'主机= “127.0.0.1”'? – ahmed 2015-04-22 18:01:31

回答

1

尝试用127.0.0.1而不是本地主机

from bottle import route, run, template 

@route('/hello/<name>') 
def index(name): 
    return template('<b>Hello {{name}}</b>!', name=name) 

run(host='127.0.0.1', port=8080) 
相关问题