docs/esp8266/tutorial: Make http_get sample function self contained.
@@ -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')
