-AP mode, devices receive test web page fine
-Script is in the boot
-LED turns Green as soon as the board is powered (not in the script)
How can I stop the script from running at power up so it can be found by the PC?
What is in my basic Script that is causing it?
I thought I knew enough but I was wrong
My Test Script for first Web Server:
Code: Select all
# MicroPython boot.py
try:
import usocket as socket
except:
import socket
import network
wl_ap = network.WLAN(1)
wl_ap.config(essid='PYBD') # set AP SSID
wl_ap.config(password='pybd0123') # set AP password
wl_ap.config(channel=6) # set AP channel
wl_ap.active(1) # enable the AP
wl_ap.status('stations') # get a list of connection stations
#wl_ap.active(0)
while wl_ap.isconnected() == False:
pass
def web_page(request):
html = """<html><head> <title>Matts Web Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="data:,"> <style>
html{font-family: Helvetica; display:inline-block; margin: 0px auto; text-align: center;}
h1{color: #0F3376; padding: 2vh;}p{font-size: 1.5rem;}
.button{display: inline-block; background-color: #e7bd3b; border: none;
border-radius: 4px; color: white; text-decoration: none; font-size: 30px; width:100%}
.button2{background-color: #4286f4; width:49%}
</style></head>
<body> <h1>Matts Web Page</h1>
</body></html>"""
return html
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', 80))
s.listen(1)
while True:
conn, addr = s.accept()
print('Got a connection from %s' % str(addr))
request = conn.recv(1024)
request = str(request)
print('The Content = %s' % request)
response = web_page(request)
conn.send(response)
conn.close()