我的404 not found 显示不出来 为什么?

import socket module

from socket import *

serverSocket = socket(AF_INET, SOCK_STREAM)

Prepare a sever socket

serverSocket.bind(('', 6789))
serverSocket.listen(1)
while True:
print('Ready to serve...')
# Establish the connection
connectionSocket, addr = serverSocket.accept()
try:
message = connectionSocket.recv(1024)
filename = message.split()[1]
f = open(filename[1:])
outputdata = f.read()
# Send one HTTP header line into socket
header = ' HTTP/1.1 200 OK\nConnection: close\nContent-Type: text/html\nContent-Length: %d\n\n' % (
len(outputdata))
connectionSocket.send(header.encode())
# Send the content of the requested file to the client
for i in range(0, len(outputdata)):
connectionSocket.send(outputdata[i].encode())
connectionSocket.send("\r\n".encode())
connectionSocket.close()
except IOError:
# Send response message for file not found
header = ' HTTP/1.1 404 file not Found'
connectionSocket.send(header.encode())
# Close client socket
connectionSocket.close()
serverSocket.close()

https://jingyan.baidu.com/article/4ae03de3d7b9c43eff9e6b1d.html