micropython-lib/python-ecosys/aiohttp
Angus Gratton 6c6fab1db1 all: Enable ruff F841 'Local variable is assigned to but never used'.
Most of these look like they were used for print debugging and then kept in
when the print statements were removed or commented.

Some look like missing or incomplete functionality, these have been marked
with comments where possible.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-05-15 18:05:21 +10:00
..
aiohttp all: Enable ruff F841 'Local variable is assigned to but never used'. 2024-05-15 18:05:21 +10:00
examples aiohttp: Add new aiohttp package. 2023-12-20 16:26:04 +11:00
README.md aiohttp: Add new aiohttp package. 2023-12-20 16:26:04 +11:00
manifest.py aiohttp: Fix binary data treatment. 2024-02-08 19:02:26 +11:00

README.md

aiohttp is an HTTP client module for MicroPython asyncio module, with API mostly compatible with CPython aiohttp module.

[!NOTE] Only client is implemented.

See examples/client.py

import aiohttp
import asyncio

async def main():

    async with aiohttp.ClientSession() as session:
        async with session.get('http://micropython.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())
$ micropython examples/client.py
Status: 200
Content-Type: text/html; charset=utf-8
Body: <!DOCTYPE html> ...