Browse Source

fix(encoding): due to windows compatibility, encoding change to utf-8

master
louisyoungx 3 years ago
parent
commit
64417eb07e
  1. 2
      Server/api.py
  2. 6
      Server/handler.py

2
Server/api.py

@ -17,7 +17,7 @@ glo = Global() @@ -17,7 +17,7 @@ glo = Global()
def log(request):
file_path = config.path() + config.settings("Logger", "FILE_PATH") + \
config.settings("Logger", "FILE_NAME")
file_page_file = open(file_path, 'r')
file_page_file = open(file_path, 'r', encoding="utf-8")
return str(file_page_file.read())

6
Server/handler.py

@ -95,19 +95,19 @@ class RequestHandler(BaseHTTPRequestHandler): @@ -95,19 +95,19 @@ class RequestHandler(BaseHTTPRequestHandler):
self.send_header("Content-Type", "application/javascript")
elif file_name[-4:] == ".png": # 二进制文件
self.send_header("Content-Type", "img/png")
file_page_file = open(file_path, 'rb', encoding="utf-8")
file_page_file = open(file_path, 'rb')
self.end_headers()
self.wfile.write(file_page_file.read())
return
elif file_name[-4:] == ".jpg": # 二进制文件
self.send_header("Content-Type", "img/jpg")
file_page_file = open(file_path, 'rb', encoding="utf-8")
file_page_file = open(file_path, 'rb')
self.end_headers()
self.wfile.write(file_page_file.read())
return
elif file_name[-4:] == ".ico": # 二进制文件
self.send_header("Content-Type", "img/ico")
file_page_file = open(file_path, 'rb', encoding="utf-8")
file_page_file = open(file_path, 'rb')
self.end_headers()
self.wfile.write(file_page_file.read())
return

Loading…
Cancel
Save