def send_request(connection):
data = connection.recv(1024).decode('utf-8')
get_request = data.split('GET /')[1].split('HTTP/')[0].strip()
try:
price = int(get_request)
except ValueError:
content = b'Error'
else:
content = str(Algorithm(products_base, rating_base).build(price)).encode('utf-8')
connection.send(b'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n')
connection.send(content)
if __name__ == '__main__':
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('127.99.83.100', 2000))
server.listen(1)
while True:
connection, address = server.accept()
connection_thread = threading.Thread(target=send_request, args=(connection,))
connection_thread.start()
Должно придти вот это:
(14270, [('null', 'Процессор Intel Core i3 Haswell i3-4170 OEM', 5839, '/INTEL-I3-4170-OEM.htm', 'i3-4170 ', '1150', 54, 2, 4, '22', 3.7, 'null'), ('./cache/img/1805332.jpg', 'Система охлаждения ID-COOLING SE-913-B ', 948, '/ID-COOLING-SE-913-B.htm', 'активный кулер', 130, 1, 2200, 122, '1150, 1155/1156, 1151/1151 v2, 1200', 'am2/am3/fm1/fm2, am4'), ('./cache/img/1204981.jpg', 'Материнская плата AFOX IH81-MA ', 3650, '/AFOX-IH81-MA.htm', '1150', 'intel h81', '3', 1600, 2, 'micro-atx', 'hdmi', 'pci-e 16x - 1 шт'), ('null', 'Оперативная память Hynix HMT DDR3 1x4Gb HMT451U6BFR8C-PBN0', 2041, '/HYNIX-HMT451U6BFR8C-PBN0.htm', '3', 4, 1600, '11-11-11-30'), ('./cache/img/173326.jpg', 'Блок питания Gembird CCC CCC-PSU7', 203, '/GEMBIRD-CCC-PSU7.htm', 550, 'atx', '24+4 pin, 1 x 6 pin', 'sata 2 шт, molex (ide) 6 шт'), ('./cache/img/140964.jpg', 'Жесткий диск Hitachi Deskstar 7K1000.C HDS721016CLA382 160\xa0ГБ', 1589, '/HITACHI-HDS721016CLA382.htm', 160, 7200, 'внутренний', '3.5')])
А выводится вот это: