try: cl, addr = s.accept() print('client connected from', addr) request = cl.recv(1024) request = str(request) print("request: {}".format(request)) led_on = request.find('/dioda/on') led_off = request.find('/dioda/off') text_index = request.find('/text') print( 'text = ' + str(text_index)) print( 'led on = ' + str(led_on)) print( 'led off = ' + str(led_off)) if text_index == 6: entrypoint_text = request[text_index+len('/text/'):] text = entrypoint_text[:entrypoint_text.find(' ')] print('Hello world {}'.format(text)) if led_on == 6: led.on() else: led.off() response = html response = html % stateis cl.send('HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n') cl.send(response) cl.close() except OSError as e: cl.close() print('connection closed')