def do_GET(self):
print("GET-Request from " + str(self.client_address))
try:
self.send_response(200) # http-code: 200 -> OK
self.send_header("Content-type", self.getMimeType())
self.end_headers()
if((self.getMimeType() != None) and (self.getMimeType().find("text") != -1)): # text file
contentBytes = self.getContent()
get = ""
# if get != "":
# content = parser.parse(contentBytes.decode("utf-8"), self.getPath(), GET=get)
#else:
content = parser.parse(contentBytes.decode("utf-8"), self.getPath())
self.wfile.write(bytes(content, "utf-8"))
else: # binary file, for example: jpg, png, pdf etc..
self.wfile.write(self.getContent())
except FileNotFoundError as fnfe:
print("File not found: " + str(fnfe))
except IOError:
self.send_error(404, "File not found: " + self.path)
评论列表
文章目录