Skip to content

Commit cbf2381

Browse files
Update aiohttp.md
1 parent dfd9021 commit cbf2381

1 file changed

Lines changed: 14 additions & 35 deletions

File tree

content/pages/projects/aiohttp.md

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,20 @@
11
Title: Aiohttp
2+
Links: Docs=https://docs.aiohttp.org/en/stable/
3+
Github=https://github.com/aio-libs/aiohttp/
24

3-
![]({static}/images/aiohttp.svg)
5+
An asynchronous HTTP Client/Server for Python's [asyncio](https://docs.python.org/3/library/asyncio.html).
46

5-
An asynchronous HTTP Client/Server for asyncio and Python.
7+
As a [client](https://docs.aiohttp.org/en/stable/client.html), aiohttp has everything you'd expect plus:
68

7-
Client example:
9+
- [WebSocket](https://docs.aiohttp.org/en/stable/client_quickstart.html#websockets) support.
10+
- [Middlewares](https://docs.aiohttp.org/en/stable/client_advanced.html#client-middleware) to customise request/response processing.
11+
- [Tracing](https://docs.aiohttp.org/en/stable/tracing_reference.html).
12+
- High performance.
813

9-
:::python
10-
import aiohttp
11-
import asyncio
14+
As a [web server/framework](https://docs.aiohttp.org/en/stable/web.html), aiohttp has everything you'd expect plus:
1215

13-
async def main():
14-
15-
async with aiohttp.ClientSession() as session:
16-
async with session.get('http://python.org') as response:
17-
18-
print("Status:", response.status)
19-
print("Content-type:", response.headers['content-type'])
20-
21-
html = await response.text()
22-
print("Body:", html[:15], "...")
23-
24-
asyncio.run(main())
25-
26-
Server example:
27-
28-
:::python
29-
from aiohttp import web
30-
31-
async def handle(request):
32-
name = request.match_info.get('name', "Anonymous")
33-
text = "Hello, " + name
34-
return web.Response(text=text)
35-
36-
app = web.Application()
37-
app.add_routes([web.get('/', handle),
38-
web.get('/{name}', handle)])
39-
40-
if __name__ == '__main__':
41-
web.run_app(app)
16+
- [WebSocket](https://docs.aiohttp.org/en/stable/web_quickstart.html#websockets) support.
17+
- [Middlewares](https://docs.aiohttp.org/en/stable/web_advanced.html#middlewares) to customise request/response processing.
18+
- Optional [handler cancellation](https://docs.aiohttp.org/en/stable/web_advanced.html#web-handler-cancellation) when a client disconnects.
19+
- High performance.
20+
- An extensive collection of [first and third party libraries](https://docs.aiohttp.org/en/stable/third_party.html) extending the base functionality.

0 commit comments

Comments
 (0)