import machine import socket pin2 = machine.Pin(2, machine.Pin.OUT) pin2.on() addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1] s = socket.socket() s.bind(addr) s.listen(1) # print('listening on', addr) while True: cl, addr = s.accept() print('client connected from', addr) cl_file = cl.makefile('rwb', 0) while True: line = cl_file.readline() # print(line) loc = str(line).find('/?PIN=ON') if (loc == 6): pin2.on() loc = str(line).find('/?PIN=OFF') if (loc == 6): pin2.off() if not line or line == b'\r\n': break response = "\n" response = response + "\n" response = response + " ESP8266 Pin Toggle \n" response = response + "

ESP8266 Pin Toggle

\n" response = response + "
\n" response = response + "" response = response + "  " response = response + "" response = response + "
\n" if (pin2.value() == 1) : response = response + "

Current Value is ON

\n" else : response = response + "

Current Value is OFF

\n" response = response + "\n" response = response + "\n" cl.send(response) cl.close()