boot.py
————————————-
try: import usocket as socket except: import socket import network import esp esp.osdebug(None) import gc gc.collect() ssid = 'REPLACE_WITH_YOUR_SSID' password = 'REPLACE_WITH_YOUR_PASSWORD' station = network.WLAN(network.STA_IF) station.active(True) station.connect(ssid, password) while station.isconnected() == False: pass print('Connection successful') print(station.ifconfig())
————————————–
main.py
————————————–
def web_page(): html = """<html><head><meta name="viewport" content="width=device-width, initial-scale=1"></head> <body><h1>Hello, World!</h1></body></html>""" return html s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', 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' % str(request)) response = web_page() conn.send('HTTP/1.1 200 OK\n') conn.send('Content-Type: text/html\n') conn.send('Connection: close\n\n') conn.sendall(response) conn.close()
—————————————
Hi Ram.
Have you inserted your network credentials in the code? SSID and password?
Can you better explain what’s not working. Please provide more details.
Regards,
Sara
Hir Sara,
Hello World Web Server and ESP Web Server both are running after a modification. Actually, I didn’t replace the SSID and PASSWORD of my Wireless Router in station.connect statement in boot.py file. After replacing, it started and showed IP: 192.168.0.123. Then, after connecting my mobile to the router and placing this URL in browser, I got Hello World html page. Also I could control the led as next project.
But the ESP32’s SSID & Password never asked in this scenario any where. Why?
Truly yours’
(RAM KISHORE)
Sorry. My typing mistake “Hir Sara”. Actually, I mean “Hi Sara”.
Truly yours’
(RAM KISHORE)