You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+40-3
Original file line number
Diff line number
Diff line change
@@ -11,12 +11,31 @@ Use Thonny IDE or other IDE for upload your code in ESP8266/ESP32 board.
11
11
12
12
## Quick start
13
13
14
+
### Typical Wi-Fi connection code for ESP board
15
+
```
16
+
import network
17
+
18
+
wlan_id = "your wi-fi"
19
+
wlan_pass = "your password"
20
+
21
+
wlan = network.WLAN(network.STA_IF)
22
+
wlan.active(True)
23
+
24
+
while not wlan.isconnected():
25
+
wlan.connect(wlan_id, wlan_pass)
26
+
print("Connected... IP: " + wlan.ifconfig()[0])
27
+
```
28
+
14
29
15
30
### Hello world example
16
31
32
+
Type in browser http://IP_ADDRESS_ESP/ and you will see "HELLO WORLD" text.
33
+
17
34
```
18
35
from micropyserver import MicroPyServer
19
36
37
+
''' there should be a wi-fi connection code here '''
38
+
20
39
def hello_world(request):
21
40
''' request handler '''
22
41
server.send("HELLO WORLD!")
@@ -29,9 +48,14 @@ server.start()
29
48
```
30
49
31
50
### Add some routes
51
+
52
+
Type in browser http://IP_ADDRESS_ESP/ or http://IP_ADDRESS_ESP/another_action and your will see text "THIS IS INDEX PAGE!" or "THIS IS ANOTHER ACTION!".
53
+
32
54
```
33
55
from micropyserver import MicroPyServer
34
56
57
+
''' there should be a wi-fi connection code here '''
58
+
35
59
def show_index(request):
36
60
''' main request handler '''
37
61
server.send("THIS IS INDEX PAGE!")
@@ -50,10 +74,14 @@ server.start()
50
74
51
75
### Send JSON response example
52
76
77
+
Type in browser http://IP_ADDRESS_ESP/ and you will see JSON response.
78
+
53
79
```
54
80
from micropyserver import MicroPyServer
55
81
import json
56
82
83
+
''' there should be a wi-fi connection code here '''
0 commit comments