import network
import socket
from machine import Pin
led = Pin(2, Pin.OUT)
ap = network.WLAN(network.AP_IF)
ap.active(True)
ap.config(essid="ESP8266_LED")
s = socket.socket()
s.bind(('', 80))
s.listen(1)
while True:
conn, addr = s.accept()
request = conn.recv(1024)
if b"/on" in request:
led.on()
if b"/off" in request:
led.off()
response = """HTTP/1.1 200 OK
<html>
<body>
<a href="/on">LED AAN</a><br>
<a href="/off">LED UIT</a>
</body>
</html>
"""
conn.send(response)
conn.close()