f web_page(): if led1.value() == 1: gpio_state1="ON" else: gpio_state1="OFF" if led2.value() == 1: gpio_state2="ON" else: gpio_state2="OFF" html = """ ESP8266 Web Server

ESP8266 Web Server

GPIO5 state: """ + gpio_state1 + """

GPIO4 state: """ + gpio_state2 + """

""" return html s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', 80)) s.listen(5) while True: conn, addr = s.accept() print('Got a connection from %s' % str(addr)) request = conn.recv(1024) request = str(request) print('Content = %s' % request) led1_on = request.find('/led1=on') led1_off = request.find('/led1=off') led2_on = request.find('/led2=on') led2_off = request.find('/led2=off') if led1_on == 6: print('LED ON') led1.value(1) if led1_off== 6: print('LED OFF') led1.value(0) if led2_on == 6: print('LED ON') led2.value(1) if led2_off== 6: print('LED OFF') led2.value(0) response = web_page() conn.send(response) conn.close()