能正常运行,却产生报错
"""
第一种报错
"""
# return self.environ[‘SERVER_PROTOCOL’].upper() != 'HTTP/0.9
# TypeError: ‘NoneType’ object is not subscriptable
# 解决方法: 修改handlers.py文件
def client_is_modern(self):
"""True if client can accept status and headers"""
try:
cmp = self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
except Exception as e:
cmp = False
return cmp
"""
第二种报错
"""
# self._sock.sendall(b)
# ConnectionAbortedError: [WinError 10053] 您的主机中的软件中止了一个已建立的链接
# 解决方法 修改socketserver.py文件
def write(self, b):
try:
self._sock.sendall(b)
except Exeception as e:
self._sock.close()
with memoryview(b) as view:
return view.nbytes
"""
第三种报错
"""
# self.status.split(' ', 1)[0]
# self.bytes_sent AttributeError: 'NoneType' object has no attribute 'split'
# 解决方法 修改simple_server.py文件
class ServerHandler(SimpleHandler):
server_software = software_version
def close(self):
try:
self.request_handler.log_request(
self.status.split(' ',1)[0], self.bytes_sent
)
SimpleHandler.close(self)
except Exception as e:
SimpleHandler.close(self)
上面代码是实测之后的,各位因环境使用