summaryrefslogtreecommitdiffstatshomepage
path: root/docs/esp8266/tutorial
diff options
context:
space:
mode:
authorThiago Paes <mrprompt@gmail.com>2018-11-01 21:47:43 -0300
committerDamien George <damien.p.george@gmail.com>2019-10-16 13:52:04 +1100
commit5463ab6df6243a63a88f686113e408933956b8eb (patch)
tree29727c2278462d93cf3281351ca0c311746c4570 /docs/esp8266/tutorial
parentd1ed73ca8f5034c1128de1fd995ca15eccb05ad9 (diff)
downloadmicropython-5463ab6df6243a63a88f686113e408933956b8eb.tar.gz
micropython-5463ab6df6243a63a88f686113e408933956b8eb.zip
docs/esp8266/tutorial: Make http_get sample function self contained.
Diffstat (limited to 'docs/esp8266/tutorial')
-rw-r--r--docs/esp8266/tutorial/network_tcp.rst4
1 files changed, 2 insertions, 2 deletions
diff --git a/docs/esp8266/tutorial/network_tcp.rst b/docs/esp8266/tutorial/network_tcp.rst
index 26a2f469ce..852fc82f39 100644
--- a/docs/esp8266/tutorial/network_tcp.rst
+++ b/docs/esp8266/tutorial/network_tcp.rst
@@ -61,6 +61,7 @@ of the request you need to specify the page to retrieve.
Let's define a function that can download and print a URL::
def http_get(url):
+ import socket
_, _, host, path = url.split('/', 3)
addr = socket.getaddrinfo(host, 80)[0][-1]
s = socket.socket()
@@ -74,8 +75,7 @@ Let's define a function that can download and print a URL::
break
s.close()
-Make sure that you import the socket module before running this function. Then
-you can try::
+Then you can try::
>>> http_get('http://micropython.org/ks/test.html')