def do_GET(self):
logging.info("GET request,\nPath: %s\nHeaders:\n%s\n", str(self.path), str(self.headers))
self._set_response()
params = parse_qs(urlparse(self.path).query)
global yt1, yt2, yt3, yt4
yt1 = params['a']
yt2 = params['s']
yt3 = params['d']
yt4 = params['f']
print(yt1,yt2,yt3,yt4)
self.wfile.write("GET request for {}".format(self.path).encode('utf-8'))`
URL: http://localhost:8086/?a=b&s=t&d=e&f=g
Я получаю правильный вывод, но получаю KeyError.
KeyError: 'a'
то же самое произошло и с этим кодом.
try:
params = dict([p.split('=') for p in parsed_path[4].split('&')])
print(params)
except:
params = {}