提交 798e4d0c 编写于 作者: H HexToString

fix_encoding_bug

上级 664aeadc
......@@ -152,8 +152,8 @@ class MainService(BaseHTTPRequestHandler):
if "key" not in post_data:
return False
else:
key = base64.b64decode(post_data["key"])
with open(args.model + "/key", "w") as f:
key = base64.b64decode(post_data["key"].encode())
with open(args.model + "/key", "wb") as f:
f.write(key)
return True
......@@ -161,8 +161,8 @@ class MainService(BaseHTTPRequestHandler):
if "key" not in post_data:
return False
else:
key = base64.b64decode(post_data["key"])
with open(args.model + "/key", "r") as f:
key = base64.b64decode(post_data["key"].encode())
with open(args.model + "/key", "rb") as f:
cur_key = f.read()
return (key == cur_key)
......@@ -203,7 +203,7 @@ class MainService(BaseHTTPRequestHandler):
self.send_response(200)
self.send_header('Content-type', 'application/json')
self.end_headers()
self.wfile.write(json.dumps(response))
self.wfile.write(json.dumps(response).encode())
if __name__ == "__main__":
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册