Skip to content

Commit

Permalink
Demonstrate usage in 'Quick start' section
Browse files Browse the repository at this point in the history
  • Loading branch information
vyahello committed May 30, 2020
1 parent 8ea9215 commit 0863a41
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,35 @@ pip install aiorequest

### Quick start

TBD
```python
>>> import asyncio
>>> from aiorequest.sessions import Session, HttpSession
>>> from aiorequest.responses import Response
>>> from aiorequest.urls import HttpUrl
>>>
>>> async def demo() -> None:
... session: Session
... async with HttpSession() as session:
... response: Response = await session.get(HttpUrl(host="xkcd.com", path="info.0.json"))
... print(await response.is_ok())
... print(await response.as_json())
...
>>> asyncio.run(demo())
True
{
"month": "3",
"num": 2284,
"link": "",
"year": "2020",
"news": "",
"safe_title": "Sabotage",
"transcript": "",
"alt": "So excited to see everyone after my cruise home from the World Handshake Championships!",
"img": "https://imgs.xkcd.com/comics/sabotage.png",
"title": "Sabotage",
"day": "23",
}
```

### Source code

Expand Down

0 comments on commit 0863a41

Please sign in to comment.