summaryrefslogtreecommitdiff
path: root/examples/network/http_client.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/network/http_client.py')
-rw-r--r--examples/network/http_client.py30
1 files changed, 0 insertions, 30 deletions
diff --git a/examples/network/http_client.py b/examples/network/http_client.py
deleted file mode 100644
index 0791c8066..000000000
--- a/examples/network/http_client.py
+++ /dev/null
@@ -1,30 +0,0 @@
-try:
- import usocket as socket
-except:
- import socket
-
-
-def main(use_stream=False):
- s = socket.socket()
-
- ai = socket.getaddrinfo("google.com", 80)
- print("Address infos:", ai)
- addr = ai[0][-1]
-
- print("Connect address:", addr)
- s.connect(addr)
-
- if use_stream:
- # MicroPython socket objects support stream (aka file) interface
- # directly, but the line below is needed for CPython.
- s = s.makefile("rwb", 0)
- s.write(b"GET / HTTP/1.0\r\n\r\n")
- print(s.read())
- else:
- s.send(b"GET / HTTP/1.0\r\n\r\n")
- print(s.recv(4096))
-
- s.close()
-
-
-main()