import socket
import network #importing network
#import gc
#gc.collect()
ssid = 'ESP32_RPI_PICO_AP' #Set access point name
password = '12345678' #Set your access point password
ap = network.WLAN(network.AP_IF)
ap.config(essid=ssid, password=password)
ap.active(True) #activating
while ap.active() == False:
pass
print('Coneccion exitosa')
print(ap.ifconfig())
def web_page():
html = """<!DOCTYPE html>
<html>
<head> <title>Pico W ESP32</title> </head>
<body>
<h1> Pico W ESP32 </h1>
<h2> Microprocesadores </h2>
<p> </p>
<h3> German Jesus Pereira Munoz PhD. </h3>
</body>
</html>
"""
return html
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #creating socket object
s.bind(('', 80))
s.listen(5)
while True:
conn, addr = s.accept()
print('Coneccion establecida de %s' % str(addr))
request = conn.recv(1024)
print('Respuesta = %s' % str(request))
response = web_page()
conn.send(response)
conn.close()