Skip to main content

This project is a branch of aiohttp on QPython.

Async http client/server framework (asyncio)

Project description:

  • Supports both client and server side of HTTP protocol.

  • Supports both client and server Web-Sockets out-of-the-box and avoids Callback Hell.

  • Provides Web-server with middleware and pluggable routing.

Getting started

Client

To get something from the web:

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())

Server

An example using a simple server:

# examples/server_simple.py
from aiohttp import web

async def handle(request):
    name = request.match_info.get('name', "Anonymous")
    text = "Hello, " + name
    return web.Response(text=text)

async def wshandle(request):
    ws = web.WebSocketResponse()
    await ws.prepare(request)

    async for msg in ws:
        if msg.type == web.WSMsgType.text:
            await ws.send_str("Hello, {}".format(msg.data))
        elif msg.type == web.WSMsgType.binary:
            await ws.send_bytes(msg.data)
        elif msg.type == web.WSMsgType.close:
            break

    return ws


app = web.Application()
app.add_routes([web.get('/', handle),
                web.get('/echo', wshandle),
                web.get('/{name}', handle)])

if __name__ == '__main__':
    web.run_app(app)

Metadata

Release files for aiohttp-qpython 3.10.10.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiohttp-qpython 3.10.10.1
File Size Uploaded
aiohttp_qpython-3.10.10.1.tar.gz 918.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiohttp-qpython 3.10.10.1
File Interpreter ABI Platform
aiohttp_qpython-3.10.10.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.9 MB

Release files / aiohttp_qpython-3.10.10.1.tar.gz

Download URL aiohttp_qpython-3.10.10.1.tar.gz
Size 918.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dfaf21d52a21d447294aa0f27e71e046d7f8476b03b7c3439604c9d026340048
BLAKE2b-256 checksum
How to use checksums
e0389b54b340379a6151ab33ebb301d481eedd9f1fd66c98d9ad83b173a5dfa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.7

Release files / aiohttp_qpython-3.10.10.1-py3-none-any.whl

Download URL aiohttp_qpython-3.10.10.1-py3-none-any.whl
Size 945.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
632fa670c6765161eb7b211fb3694f09594d6f09df105bb28dcaa84887e9fdd1
BLAKE2b-256 checksum
How to use checksums
29e43618e2c4711aa79acb45444ed949df8a29bedb48b32ee10f202f2e0e8fe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

3.10.10.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page