python / 12. Asynchronous Python - 2 /21.2 0_first_async_request.py
hero-nq1310's picture
Upload 12 files
3a05423 verified
raw
history blame contribute delete
317 Bytes
import aiohttp
import asyncio
async def fetch_page(url):
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
print(response.status)
return response.status
loop = asyncio.get_event_loop()
loop.run_until_complete(fetch_page('http://google.com'))