Skip to content

Commit

Permalink
Use async/await in the readme example
Browse files Browse the repository at this point in the history
  • Loading branch information
twm committed Apr 30, 2024
1 parent f0c668e commit 22769b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
treq: High-level Twisted HTTP Client API
========================================

|pypi|_
|calver|_
|coverage|_
|documentation|_
|pypi|
|calver|
|coverage|
|documentation|

``treq`` is an HTTP library inspired by
`requests <https://requests.readthedocs.io/>`_ but written on top of
Expand All @@ -18,15 +18,16 @@ using Twisted.
>>> import treq
>>> def done(response):
>>> async def main(reactor):
... response = await treq.get("https:")
... print(response.code)
... reactor.stop()
... body = await response.text()
... print("<!DOCTYPE html>" in body)
>>> treq.get("https:").addCallback(done)
>>> from twisted.internet import reactor
>>> reactor.run()
>>> from twisted.internet.task import react
>>> react(main)
200
True
For more info `read the docs <https://treq.readthedocs.org>`_.

Expand All @@ -35,7 +36,7 @@ Contributing

``treq`` development is hosted on `GitHub <https:/twisted/treq>`_.

We welcome contributions: feel to fork and send contributions over.
We welcome contributions: feel free to fork and send contributions over.
See `CONTRIBUTING.rst <https:/twisted/treq/blob/master/CONTRIBUTING.rst>`_ for more info.

Code of Conduct
Expand Down
Empty file added changelog.d/382.misc.rst
Empty file.

0 comments on commit 22769b8

Please sign in to comment.