http client/server for asyncio
Project description
http client/server for asyncio
Requirements
Python >= 3.3
License
aiohttp is offered under the Apache 2 license.
Documentation
Getting started
Client
To retrieve something from the web:
import aiohttp def get_body(url): response = yield from aiohttp.request('GET', url) return (yield from response.read())
You can use the get command like this anywhere in your asyncio powered program:
response = yield from aiohttp.request('GET', 'http://python.org') body = yield from response.read() print(body)
If you want to use timeouts for aiohttp client side please use standard asyncio approach:
yield from asyncio.wait_for(request('GET', url), 10)
Server
In aiohttp 0.12 we’ve added highlevel API for web HTTP server.
There is simple usage example:
import asyncio from aiohttp import web @asyncio.coroutine def handle(request): name = request.match_info.get('name', "Anonymous") text = "Hello, " + name return web.Response(body=text.encode('utf-8')) @asyncio.coroutine def init(loop): app = web.Application(loop=loop) app.router.add_route('GET', '/{name}', handle) srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 8080) print("Server started at http://127.0.0.1:8080") return srv loop = asyncio.get_event_loop() loop.run_until_complete(init(loop)) loop.run_forever()
CHANGES
0.13.0 (12-29-2014)
StreamResponse.charset converts value to lower-case on assigning.
Chain exceptions when raise ClientRequestError.
Support custom regexps in route variables #204
Fixed graceful shutdown, disable keep-alive on connection closing.
Decode http message with utf-8 encoding, some servers send headers in utf-8 encoding #207
Support aiohtt.web middlewares #209
Add ssl_context to TCPConnector #206
0.12.0 (12-12-2014)
Deep refactoring of aiohttp.web in backward-incompatible manner. Sorry, we have to do this.
Automatically force aiohttp.web handlers to coroutines in UrlDispatcher.add_route() #186
Rename Request.POST() function to Request.post()
Added POST attribute
Response processing refactoring: constructor does’t accept Request instance anymore.
Pass application instance to finish callback
Exceptions refactoring
Do not unquote query string in aiohttp.web.Request
Fix concurrent access to payload in RequestHandle.handle_request()
Add access logging to aiohttp.web
Gunicorn worker for aiohttp.web
Removed deprecated AsyncGunicornWorker
Removed deprecated HttpClient
0.11.0 (11-29-2014)
Support named routes in aiohttp.web.UrlDispatcher #179
Make websocket subprotocols conform to spec #181
0.10.2 (11-19-2014)
Don’t unquote environ[‘PATH_INFO’] in wsgi.py #177
0.10.1 (11-17-2014)
aiohttp.web.HTTPException and descendants now files response body with string like 404: NotFound
Fix multidict __iter__, the method should iterate over keys, not (key, value) pairs.
0.10.0 (11-13-2014)
Add aiohttp.web subpackage for highlevel http server support.
Add reason optional parameter to aiohttp.protocol.Response ctor.
Fix aiohttp.client bug for sending file without content-type.
Change error text for connection closed between server responses from ‘Can not read status line’ to explicit ‘Connection closed by server’
Drop closed connections from connector #173
Set server.transport to None on .closing() #172
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aiohttp-0.13.0.tar.gz
.
File metadata
- Download URL: aiohttp-0.13.0.tar.gz
- Upload date:
- Size: 806.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a77e4dfc33f72307af5228aea4ee3039bc9ede7d363bceca244851995c34a30d |
|
MD5 | 594b508117879d9ff7669c9132b237db |
|
BLAKE2b-256 | 435b22a44aa15d7cd9a1e1bcf5966948e820609de4f5e970bd8e0996c118e131 |
Provenance
File details
Details for the file aiohttp-0.13.0-py3-none-any.whl
.
File metadata
- Download URL: aiohttp-0.13.0-py3-none-any.whl
- Upload date:
- Size: 67.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0d21e0a485d989a4554069436cf3ca573ec391d6e307c8d92eba04a3dfd8fd9 |
|
MD5 | ee0f562df86cb5266fc75c14b104c493 |
|
BLAKE2b-256 | be3373931ba4cec891a50bf45de12b8c3f13d7db191c2c4672cac4d4ae3f2946 |