def do_POST(self): content_length = int(self.headers['Content-Length']) # <--- Gets the size of data data_bytes = self.rfile.read(content_length) # <--- Gets the data itself data_str = data_bytes.decode('utf-8') path = self.path headers = self.headers var = parse_qs(data_str) print("Var: ", var) if path != "/spotzc" or 'action' not in var or 'addUser' not in var['action']: self._set_404_headers() return user_name = var['userName'][0].encode() blob_bytes = var['blob'][0].encode() client_key = var['clientKey'][0].encode() device_name = var['deviceName'][0] response = json.dumps( { "status": 101, "spotifyError": 0, "statusString": "ERROR-OK" }).encode() self._set_200_headers('Content-Length', str(len(response))) self.wfile.write(response) blob = Blob() login = blob.decrypt(self.keys, blob_bytes, client_key, user_name, DEVICE_ID) self.server.notify_listener(blob) with open('credentials/' + device_name + '.dat', 'w') as f: f.write(text_format.MessageToString(login)) f.close() '''