From 7d84408cdacf6c8fa81b502abffae12da5767e18 Mon Sep 17 00:00:00 2001 From: Florimond Manca Date: Tue, 14 Jan 2020 10:01:09 +0100 Subject: [PATCH] Add an async example to intro snippets (#750) --- README.md | 12 ++++++++++++ docs/index.md | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/README.md b/README.md index cf6b9b3a..27fd542e 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,18 @@ Let's get started... '\n\n\nExample Domain...' ``` +Or, using the async API... + +_Use [IPython](https://ipython.readthedocs.io/en/stable/) or Python 3.8+ with `python -m asyncio` to try this code interactively._ + +```python +>>> import httpx +>>> async with httpx.AsyncClient() as client: +>>> r = await client.get('https://www.example.org/') +>>> r + +``` + ## Features HTTPX builds on the well-established usability of `requests`, and gives you: diff --git a/docs/index.md b/docs/index.md index e3d6e2a5..476f62af 100644 --- a/docs/index.md +++ b/docs/index.md @@ -51,6 +51,18 @@ Let's get started... '\n\n\nExample Domain...' ``` +Or, using the async API... + +_Use [IPython](https://ipython.readthedocs.io/en/stable/) or Python 3.8+ with `python -m asyncio` to try this code interactively._ + +```python +>>> import httpx +>>> async with httpx.AsyncClient() as client: +>>> r = await client.get('https://www.example.org/') +>>> r + +``` + ## Features HTTPX is a high performance asynchronous HTTP client, that builds on the -- 2.47.3