import network
import socket
AP_SSID = ‘ESP32-AP’
AP_PASSWORD = ‘88888888’
ap = network.WLAN(network.AP_IF)
ap.active(True)
ap.config(essid=‘ESP32-AP’, authmode=network.AUTH_WPA_WPA2_PSK, password=‘88888888’)
#print(‘AP IP address:’, ap.ifconfig()[0])
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((‘0.0.0.0’, 80))
s.listen(5)
def handle_request(conn):
request = conn.recv(1024)
response = ‘HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\nHello! from ESP32’
conn.send(response.encode())
conn.close()
while True:
conn, addr = s.accept()
print(‘Got a connection from %s’ % str(addr))
handle_request(conn)
-----------------------------------