提交 2125d711 编写于 作者: J Jiawei Wang 提交者: wangjiawei04

Merge pull request #1035 from HexToString/fix_encoding_bug

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