Skip to main content

aiohttp-things

Read The Docs build Release MIT License Python version support PyPI downloads count GitHub continuous integration

Modest utility collection for development with AIOHTTP framework.

Documentation

https://aiohttp-things.readthedocs.io

Installation

Installing aiohttp-things with pip:

pip install aiohttp-things

Simple example

Example of AIOHTTP application

import json
import uuid
import aiohttp_things as ahth
from aiohttp import web


def safe_json_value(value):
    try:
        json.dumps(value)
        return value
    except (TypeError, OverflowError):
        return str(value)


class Base(web.View, ahth.JSONMixin, ahth.PrimaryKeyMixin):
    async def get(self):
        self.context['Type of primary key'] = safe_json_value(type(self.pk))
        self.context['Value of primary key'] = safe_json_value(self.pk)
        return await self.finalize_response()


class IntegerExample(Base):
    pk_adapter = int


class UUIDExample(Base):
    pk_adapter = uuid.UUID


UUID = '[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}'
ROUTES = [
    web.view('/integer/{pk:[0-9]+}', IntegerExample),
    web.view(f'/uuid/{{pk:{UUID}}}', UUIDExample),
]


async def app_factory():
    app = web.Application()
    app.add_routes(ROUTES)
    return app


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

Examples HTTP requests and response

  • http://0.0.0.0:8080/integer/1

    {
      "Type of primary key": "<class 'int'>",
      "Value of primary key": 1
    }
  • http://0.0.0.0:8080/integer/9999999999999

    {
      "Type of primary key": "<class 'int'>",
      "Value of primary key": 9999999999999
    }
  • http://0.0.0.0:8080/integer/a352da04-c1af-4a44-8a94-c37f8f37b2bc

    404: Not Found
  • http://0.0.0.0:8080/integer/abc

    404: Not Found
  • http://0.0.0.0:8080/uuid/a352da04-c1af-4a44-8a94-c37f8f37b2bc

    {
      "Type of primary key": "<class 'uuid.UUID'>",
      "Value of primary key": "a352da04-c1af-4a44-8a94-c37f8f37b2bc"
    }
  • http://0.0.0.0:8080/uuid/13d1d0e0-4787-4feb-8684-b3da32609743

    {
      "Type of primary key": "<class 'uuid.UUID'>",
      "Value of primary key": "13d1d0e0-4787-4feb-8684-b3da32609743"
    }
  • http://0.0.0.0:8080/uuid/1

    404: Not Found
  • http://0.0.0.0:8080/uuid/abc

    404: Not Found

Metadata

Release files for aiohttp-things 1.2.post0

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-things 1.2.post0
File Size Uploaded Provenance Actions
aiohttp_things-1.2.post0.tar.gz 4.8 kB Without provenance Details for aiohttp_things-1.2.post0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiohttp-things 1.2.post0
File Interpreter ABI Platform Actions
aiohttp_things-1.2.post0-py3-none-any.whl Python 3 none any Details for aiohttp_things-1.2.post0-py3-none-any.whl

Total release size: 10.5 kB

Release files / aiohttp_things-1.2.post0.tar.gz

Download URL aiohttp_things-1.2.post0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
03461ab57be173a40d29051addae37274f99f82bb75fd54855b9b924a25c8a54
BLAKE2b-256 checksum
How to use checksums
8a5029d6cf1ee65b2ee7524b4e95c69ecf2e8725f822ac2bdb21b79c3ed12fe4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.12.3 Linux/6.8.0-90-generic

Release files / aiohttp_things-1.2.post0-py3-none-any.whl

Download URL aiohttp_things-1.2.post0-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8732236115692a8d4399045ab3d754d2c05205d4d1c400366011fd63d26297c
BLAKE2b-256 checksum
How to use checksums
d0ee08043a3b10d70831b8f68195c57d766f28f4a861e9b2a784e43123994b22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.12.3 Linux/6.8.0-90-generic

Security for aiohttp-things 1.2.post0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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