django正常運行確報錯的解決方法


django正常運行卻報錯的處理方法

出處 : https://www.infvie.com/ops-notes/django-normal-operation-error

報錯一:self._sock.sendall(b) ConnectionAbortedError: [WinError 10053] 您的主機中的軟件中止了一個已建立的連接。

解決方法:找到python/Lib/socketserver.py文件,修改SocketWriter類的write方法,具體如下:

def write(self, b):
    try:
        self._sock.sendall(b)
    except Exception as e:
        self._sock.close()
    with memoryview(b) as view:
        return view.nbytes

 

報錯二:return self.environ[‘SERVER_PROTOCOL’].upper() != 'HTTP/0.9 TypeError: ‘NoneType’ object is not subscriptable

解決方法:打開python\lib\wsgiref\handlers.py文件,修改client_is_modern函數,具體如下:

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.status.split(’ ',1)[0], self.bytes_sent AttributeError: ‘NoneType’ object has no attribute 'split

解決方法:打開python\lib\wsgiref\simple_server.py文件,修改ServerHandler類,具體如下:

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)

 

報錯四:“GET /favicon.ico HTTP/1.1” 404 3163

解決方法:在static文件下的image文件添加一個favicon.ico圖片,然后在頁面頭部加入

注:具體路徑看自己定義的內容,或有差異.

 

報錯五:GET /c_hello?asker=backuper HTTP/1.1" 404 3166 Not Found: /c_hello

解決方法:暫時未找到!!!有懂得解決的希望分享一下,或者我后續找到了再更新一下。

 
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM