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 11#
22# uaiohttpclient - fetch URL passed as command line argument.
33#
4+ import sys
45import uasyncio as asyncio
56import uaiohttpclient as aiohttp
67
78
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 )
2011 print (resp )
21- yield from print_stream ( resp )
12+ print ( await resp . read () )
2213
2314
24- import sys
25- import logging
26-
27- logging .basicConfig (level = logging .INFO )
2815url = 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