-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccessPoint.py
43 lines (34 loc) 路 888 Bytes
/
AccessPoint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
try:
import usocket as socket
except:
import socket
import network
ssid = 'ScaryBug'
password = '123456789'
ap = network.WLAN(network.AP_IF)
ap.active(True)
ap.config(essid=ssid, password=password)
while ap.active() == False:
pass
print(ap.ifconfig())
def web_page():
html = """<html><head><meta name="viewport" content="width=device-width, initial-scale=1"></head>
<body><h1>Hello, Hackers!</h1></body></html>"""
return html
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', 80))
s.listen(5)
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(response)
from machine import Pin
from time import sleep
led = Pin(2, Pin.OUT)
while True:
sleep(1);led.value(1)
conn.send(response)
sleep(1);led.value(0)
sleep(1);led.value(1)