We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 05efdd0 commit 9ceda53Copy full SHA for 9ceda53
micropython/uaiohttpclient/example.py
@@ -1,31 +1,16 @@
1
#
2
# uaiohttpclient - fetch URL passed as command line argument.
3
4
+import sys
5
import uasyncio as asyncio
6
import uaiohttpclient as aiohttp
7
8
-def print_stream(resp):
9
- print((yield from resp.read()))
10
- return
11
- while True:
12
- line = yield from resp.readline()
13
- if not line:
14
- break
15
- print(line.rstrip())
16
-
17
18
-def run(url):
19
- resp = yield from aiohttp.request("GET", url)
+async def run(url):
+ resp = await aiohttp.request("GET", url)
20
print(resp)
21
- yield from print_stream(resp)
+ print(await resp.read())
22
23
24
-import sys
25
-import logging
26
27
-logging.basicConfig(level=logging.INFO)
28
url = sys.argv[1]
29
-loop = asyncio.get_event_loop()
30
-loop.run_until_complete(run(url))
31
-loop.close()
+asyncio.run(run(url))
0 commit comments