Replies: 1 comment 2 replies
-
You can give this a try: s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((ip, 80))
s.listen(5)
while True:
conn, addr = s.accept()
print('Got a connection from %s' % str(addr))
request = conn.recv(1024)
print('Content = %s' % request.decode())
if b'/?led_2_on' in request:
print('LED ON -> GPIO2')
led_state = "ON"
led.on()
elif b'/?led_2_off' in request:
print('LED OFF -> GPIO2')
led_state = "OFF"
led.off()
else:
print('Unknown CMD') |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,

I have an ESP32 server which offers the lighting of an LED via an HTML page.
All the examples I've seen on the internet show this line:
if xxx == 6:
do this.
I saw only one explanation on this site (https://microcontrollerslab.com/esp32-esp8266-micropython-web-server/)but I find it too succinct.
The substrings '/?led_2_on' or '/?led_2_off' are always on the 6th index !!!
My question is : how to find and print the other indexes
Beta Was this translation helpful? Give feedback.
All reactions