gpt4 book ai didi

python - Bottle 试图以其权限所禁止的方式访问套接字

转载 作者:太空宇宙 更新时间:2023-11-03 17:48:27 25 4
gpt4 key购买 nike

我正在使用 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 <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

但错误仍然存​​在,我该如何解决这个问题?

最佳答案

尝试使用 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)

关于python - Bottle 试图以其权限所禁止的方式访问套接字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29425002/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com