From: Florimond Manca Date: Tue, 14 Jan 2020 09:01:09 +0000 (+0100) Subject: Add an async example to intro snippets (#750) X-Git-Tag: 0.11.1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d84408cdacf6c8fa81b502abffae12da5767e18;p=thirdparty%2Fhttpx.git Add an async example to intro snippets (#750) --- 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