summaryrefslogtreecommitdiffstats
path: root/third_party/python/aiohttp/examples/client_json.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /third_party/python/aiohttp/examples/client_json.py
parentInitial commit. (diff)
downloadthunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.tar.xz
thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/python/aiohttp/examples/client_json.py')
-rwxr-xr-xthird_party/python/aiohttp/examples/client_json.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/third_party/python/aiohttp/examples/client_json.py b/third_party/python/aiohttp/examples/client_json.py
new file mode 100755
index 0000000000..e54edeaddb
--- /dev/null
+++ b/third_party/python/aiohttp/examples/client_json.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+import asyncio
+
+import aiohttp
+
+
+async def fetch(session):
+ print("Query http://httpbin.org/get")
+ async with session.get("http://httpbin.org/get") as resp:
+ print(resp.status)
+ data = await resp.json()
+ print(data)
+
+
+async def go(loop):
+ async with aiohttp.ClientSession(loop=loop) as session:
+ await fetch(session)
+
+
+loop = asyncio.get_event_loop()
+loop.run_until_complete(go(loop))
+loop.close()