Skip to content

Commit

Permalink
Merge pull request #383 from twisted/382-async-await-readme
Browse files Browse the repository at this point in the history
Use async/await in the readme example
  • Loading branch information
twm authored May 1, 2024
2 parents ebe8f37 + 27bd085 commit eb301b5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
treq: High-level Twisted HTTP Client API
========================================

|pypi|_
|calver|_
|coverage|_
|documentation|_
.. |pypi| image:: https://img.shields.io/pypi/v/treq.svg
:alt: PyPI
:target: https://pypi.org/project/treq/

.. |calver| image:: https://img.shields.io/badge/calver-YY.MM.MICRO-22bfda.svg
:alt: calver: YY.MM.MICRO
:target: https://calver.org/

.. |coverage| image:: https://coveralls.io/repos/github/twisted/treq/badge.svg
:alt: Coverage
:target: https://coveralls.io/github/twisted/treq

.. |documentation| image:: https://readthedocs.org/projects/treq/badge/
:alt: Documentation
:target: https://treq.readthedocs.org

|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 +34,16 @@ using Twisted.
>>> import treq
>>> def done(response):
>>> async def main(reactor):
... response = await treq.get("https://github.com")
... print(response.code)
... reactor.stop()
... body = await response.text()
... print("<!DOCTYPE html>" in body)
>>> treq.get("https://github.com").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 +52,7 @@ Contributing

``treq`` development is hosted on `GitHub <https://github.com/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://github.com/twisted/treq/blob/master/CONTRIBUTING.rst>`_ for more info.

Code of Conduct
Expand All @@ -50,18 +67,3 @@ Copyright and License
See `LICENSE <./LICENSE>`_ for legal details and copyright notices.


.. _pypi: https://pypi.org/project/treq/
.. |pypi| image:: https://img.shields.io/pypi/v/treq.svg
:alt: PyPI

.. _calver: https://calver.org/
.. |calver| image:: https://img.shields.io/badge/calver-YY.MM.MICRO-22bfda.svg
:alt: calver: YY.MM.MICRO

.. _coverage: https://coveralls.io/github/twisted/treq
.. |coverage| image:: https://coveralls.io/repos/github/twisted/treq/badge.svg
:alt: Coverage

.. _documentation: https://treq.readthedocs.org
.. |documentation| image:: https://readthedocs.org/projects/treq/badge/
:alt: Documentation
Empty file added changelog.d/382.misc.rst
Empty file.

0 comments on commit eb301b5

Please sign in to comment.