File tree Expand file tree Collapse file tree 1 file changed +5
-20
lines changed
micropython/uaiohttpclient Expand file tree Collapse file tree 1 file changed +5
-20
lines changed Original file line number Diff line number Diff line change 1
1
#
2
2
# uaiohttpclient - fetch URL passed as command line argument.
3
3
#
4
+ import sys
4
5
import uasyncio as asyncio
5
6
import uaiohttpclient as aiohttp
6
7
7
8
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 )
9
+ async def run (url ):
10
+ resp = await aiohttp .request ("GET" , url )
20
11
print (resp )
21
- yield from print_stream ( resp )
12
+ print ( await resp . read () )
22
13
23
14
24
- import sys
25
- import logging
26
-
27
- logging .basicConfig (level = logging .INFO )
28
15
url = sys .argv [1 ]
29
- loop = asyncio .get_event_loop ()
30
- loop .run_until_complete (run (url ))
31
- loop .close ()
16
+ asyncio .run (run (url ))
You can’t perform that action at this time.
0 commit comments