Python async http client

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Asynchronous HTTP client/server framework for asyncio and Python

License

aio-libs/aiohttp

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

  • Typehint for function from_path no longer enforce PathLike as its first argument
  • Minor improvement over the global detection reliability
  • Introduce function is_binary that relies on main capabilities, and is optimized to detect binaries
  • Propagate enable_fallback argument throughout from_bytes, from_path, and from_fp that allow a deeper control over the detection (default True)
  • Explicit support for Python 3.12
  • Optional speedup provided by mypy/c 1.0.1
  • Speedup provided using mypy/c 0.990 on Python >= 3.7
  • Extend the capability of explain=True when cp_isolation contains at most two entries (min one), will log in details of the Mess-detector results
  • Support for alternative language frequency set in charset_normalizer.assets.FREQUENCIES
  • Add parameter language_threshold in from_bytes, from_path and from_fp to adjust the minimum expected coherence ratio
  • normalizer --version now specify if the current version provides extra speedup (meaning mypyc compilation whl)
  • Build with static metadata (not pyproject.toml yet)
  • Make language detection stricter
  • Optional: Module md.py can be compiled using Mypyc to provide an extra speedup up to 4x faster than v2.1
  • Typehint for function from_path no longer enforce PathLike as its first argument
  • Minor improvement over the global detection reliability
  • Introduce function is_binary that relies on main capabilities, and optimized to detect binaries
  • Propagate enable_fallback argument throughout from_bytes, from_path, and from_fp that allow a deeper control over the detection (default True)
  • Explicit support for Python 3.12
  • Optional speedup provided by mypy/c 1.0.1
  • Speedup provided by mypy/c 0.990 on Python >= 3.7
  • Extend the capability of explain=True when cp_isolation contains at most two entries (min one), will log in details of the Mess-detector results
  • Support for alternative language frequency set in charset_normalizer.assets.FREQUENCIES
  • Add parameter language_threshold in from_bytes, from_path and from_fp to adjust the minimum expected coherence ratio
  • normalizer --version now specify if current version provide extra speedup (meaning mypyc compilation whl)
  • Build with static metadata using ‘build’ frontend
  • Make the language detection stricter
  • Optional: Module md.py can be compiled using Mypyc to provide an extra speedup up to 4x faster than v2.1
  • CLI with opt —normalize fail when using full path for files
  • TooManyAccentuatedPlugin induce false positive on the mess detection when too few alpha character have been fed to it
  • Sphinx warnings when generating the documentation
  • If you are using the legacy detect function, that is it. You have nothing to do.

Источник

Welcome to AIOHTTP¶

Asynchronous HTTP Client/Server for asyncio and Python.

Key Features¶

  • Supports both Client and HTTP Server .
  • Supports both Server WebSockets and Client WebSockets out-of-the-box without the Callback Hell.
  • Web-server has Middlewares , Signals and plugable routing.

Library Installation¶

You may want to install optional cchardet library as faster replacement for charset-normalizer :

Note that the cchardet project is known not to support Python 3.10 or higher. See #6819 and GitHub: PyYoshi/cChardet/issues/77 for more details.

For speeding up DNS resolving by client API you may install aiodns as well. This option is highly recommended:

Installing all speedups in one command¶

The following will get you aiohttp along with cchardet , aiodns and Brotli in one bundle. No need to type separate commands anymore!

$ pip install aiohttp[speedups] 

Getting Started¶

Client example¶

import aiohttp import asyncio async def main(): async with aiohttp.ClientSession() as session: async with session.get('http://python.org') as response: print("Status:", response.status) print("Content-type:", response.headers['content-type']) html = await response.text() print("Body:", html[:15], ". ") asyncio.run(main()) 
Status: 200 Content-type: text/html; charset=utf-8 Body: .

Server example:¶

from aiohttp import web async def handle(request): name = request.match_info.get('name', "Anonymous") text = "Hello, " + name return web.Response(text=text) app = web.Application() app.add_routes([web.get('/', handle), web.get('/ ', handle)]) if __name__ == '__main__': web.run_app(app) 

For more information please visit Client and Server pages.

What’s new in aiohttp 3?¶

Go to What’s new in aiohttp 3.0 page for aiohttp 3.0 major release changes.

Tutorial¶

Source code¶

Please feel free to file an issue on the bug tracker if you have found a bug or have some suggestion in order to improve the library.

Dependencies¶

  • Python 3.6+
  • async_timeout
  • attrs
  • charset-normalizer
  • multidict
  • yarl
  • Optionalcchardet as faster replacement for charset-normalizer . Install it explicitly via:

Communication channels¶

Feel free to post your questions and ideas here.

We support Stack Overflow. Please add aiohttp tag to your question there.

Contributing¶

Please read the instructions for contributors before making a Pull Request.

Authors and License¶

The aiohttp package is written mostly by Nikolay Kim and Andrew Svetlov.

It’s Apache 2 licensed and freely available.

Feel free to improve this package and send a pull request to GitHub.

Policy for Backward Incompatible Changes¶

aiohttp keeps backward compatibility.

After deprecating some Public API (method, class, function argument, etc.) the library guaranties the usage of deprecated API is still allowed at least for a year and half after publishing new release with deprecation.

All deprecations are reflected in documentation and raises DeprecationWarning .

Sometimes we are forced to break the own rule for sake of very strong reason. Most likely the reason is a critical bug which cannot be solved without major API change, but we are working hard for keeping these changes as rare as possible.

Table Of Contents¶

Оцените статью