Python 瓶子试图以其禁止的方式进入插座';允许
我正在使用瓶子,并编写了一个简单的应用程序Python 瓶子试图以其禁止的方式进入插座';允许,python,sockets,bottle,Python,Sockets,Bottle,我正在使用瓶子,并编写了一个简单的应用程序 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 &l
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
回溯(最近一次呼叫最后一次):
文件“C:\Users\James\Desktop\application.py”,第7行,在
运行(主机=“0.0.0.0”,端口=8080)
文件“C:\Python34\lib\site packages\bottle.py”,第3117行,正在运行
server.run(应用程序)
文件“C:\Python34\lib\site packages\bottle.py”,第2771行,正在运行
srv=make_服务器(self.host、self.port、app、server_cls、handler_cls)
文件“C:\Python34\lib\wsgiref\simple\u server.py”,第153行,位于make\u服务器中
服务器=服务器类((主机、端口)、处理程序类)
文件“C:\Python34\lib\socketserver.py”,第429行,在_init中__
self.server_bind()
服务器绑定中的第50行文件“C:\Python34\lib\wsgiref\simple\u server.py”
HTTPServer.server\u绑定(self)
服务器绑定中的第133行文件“C:\Python34\lib\http\server.py”
socketserver.TCPServer.server\u绑定(self)
服务器绑定中第440行的文件“C:\Python34\lib\socketserver.py”
self.socket.bind(self.server\u地址)
OSError:[WinError 10013]试图以禁止的方式访问套接字
通过它的访问权限访问den
看看其他一些SO帖子,似乎我需要允许它通过防火墙。我做到了:
但是错误仍然存在,我该如何解决这个问题?尝试使用127.0.0.1而不是localhost
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)
从瓶子导入路线、运行、模板
@路由(“/hello/”)
def索引(名称):
返回模板('Hello{{name}}!',name=name)
运行(主机=127.0.0.1',端口=8080)
您是否尝试过host=“127.0.0.1”
?