==============
aiohttp-things
==============
|ReadTheDocs| |PyPI release| |License| |Python versions| |PyPI downloads| |GitHub CI|
.. |ReadTheDocs| image:: https://readthedocs.org/projects/aiohttp-things/badge/?version=latest
:target: https://aiohttp-things.readthedocs.io/en/latest/?badge=latest
:alt: Read The Docs build
.. |PyPI release| image:: https://badge.fury.io/py/aiohttp-things.svg
:target: https://pypi.org/project/aiohttp-things/
:alt: Release
.. |License| image:: https://img.shields.io/badge/License-MIT-green
:target: https://github.com/ri-gilfanov/aiohttp-things/blob/master/LICENSE
:alt: MIT License
.. |Python versions| image:: https://img.shields.io/badge/Python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue
:target: https://pypi.org/project/aiohttp-things/
:alt: Python version support
.. |PyPI downloads| image:: https://static.pepy.tech/personalized-badge/aiohttp-things?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Downloads
:target: https://pepy.tech/project/aiohttp-things
:alt: PyPI downloads count
.. |GitHub CI| image:: https://github.com/ri-gilfanov/aiohttp-things/actions/workflows/ci.yml/badge.svg?branch=master
:target: https://github.com/ri-gilfanov/aiohttp-things/actions/workflows/ci.yml
:alt: GitHub continuous integration
Modest utility collection for development with `AIOHTTP
<https://docs.aiohttp.org/>`_ framework.
Documentation
-------------
https://aiohttp-things.readthedocs.io
Installation
------------
Installing ``aiohttp-things`` with pip: ::
pip install aiohttp-things
Simple example
--------------
Example of AIOHTTP application
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
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
.. code-block:: json
{
"Type of primary key": "<class 'int'>",
"Value of primary key": 1
}
* \http://0.0.0.0:8080/integer/9999999999999
.. code-block:: json
{
"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
.. code-block:: json
{
"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
.. code-block:: json
{
"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
Raw data
{
"_id": null,
"home_page": "https://github.com/ri-gilfanov/aiohttp-things",
"name": "aiohttp-things",
"maintainer": "Ruslan Ilyasovich Gilfanov",
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": "ri.gilfanov@yandex.ru",
"keywords": "aiohttp, asyncio",
"author": "Ruslan Ilyasovich Gilfanov",
"author_email": "ri.gilfanov@yandex.ru",
"download_url": "https://files.pythonhosted.org/packages/a4/6d/f90e1bbd843c148eca1be50cf83ee432630a1ddeb29dc62dd4f000da0a63/aiohttp_things-1.1.0.tar.gz",
"platform": null,
"description": "==============\naiohttp-things\n==============\n|ReadTheDocs| |PyPI release| |License| |Python versions| |PyPI downloads| |GitHub CI|\n\n.. |ReadTheDocs| image:: https://readthedocs.org/projects/aiohttp-things/badge/?version=latest\n :target: https://aiohttp-things.readthedocs.io/en/latest/?badge=latest\n :alt: Read The Docs build\n\n.. |PyPI release| image:: https://badge.fury.io/py/aiohttp-things.svg\n :target: https://pypi.org/project/aiohttp-things/\n :alt: Release\n\n.. |License| image:: https://img.shields.io/badge/License-MIT-green\n :target: https://github.com/ri-gilfanov/aiohttp-things/blob/master/LICENSE\n :alt: MIT License\n\n.. |Python versions| image:: https://img.shields.io/badge/Python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue\n :target: https://pypi.org/project/aiohttp-things/\n :alt: Python version support\n\n.. |PyPI downloads| image:: https://static.pepy.tech/personalized-badge/aiohttp-things?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Downloads\n :target: https://pepy.tech/project/aiohttp-things\n :alt: PyPI downloads count\n\n.. |GitHub CI| image:: https://github.com/ri-gilfanov/aiohttp-things/actions/workflows/ci.yml/badge.svg?branch=master\n :target: https://github.com/ri-gilfanov/aiohttp-things/actions/workflows/ci.yml\n :alt: GitHub continuous integration\n\nModest utility collection for development with `AIOHTTP\n<https://docs.aiohttp.org/>`_ framework.\n\nDocumentation\n-------------\nhttps://aiohttp-things.readthedocs.io\n\n\nInstallation\n------------\nInstalling ``aiohttp-things`` with pip: ::\n\n pip install aiohttp-things\n\n\nSimple example\n--------------\nExample of AIOHTTP application\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n.. code-block:: python\n\n import json\n import uuid\n import aiohttp_things as ahth\n from aiohttp import web\n\n\n def safe_json_value(value):\n try:\n json.dumps(value)\n return value\n except (TypeError, OverflowError):\n return str(value)\n\n\n class Base(web.View, ahth.JSONMixin, ahth.PrimaryKeyMixin):\n async def get(self):\n self.context['Type of primary key'] = safe_json_value(type(self.pk))\n self.context['Value of primary key'] = safe_json_value(self.pk)\n return await self.finalize_response()\n\n\n class IntegerExample(Base):\n pk_adapter = int\n\n\n class UUIDExample(Base):\n pk_adapter = uuid.UUID\n\n\n UUID = '[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}'\n ROUTES = [\n web.view('/integer/{pk:[0-9]+}', IntegerExample),\n web.view(f'/uuid/{{pk:{UUID}}}', UUIDExample),\n ]\n\n\n async def app_factory():\n app = web.Application()\n app.add_routes(ROUTES)\n return app\n\n\n if __name__ == '__main__':\n web.run_app(app_factory())\n\nExamples HTTP requests and response\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n* \\http://0.0.0.0:8080/integer/1\n\n .. code-block:: json\n\n {\n \"Type of primary key\": \"<class 'int'>\",\n \"Value of primary key\": 1\n }\n\n* \\http://0.0.0.0:8080/integer/9999999999999\n\n .. code-block:: json\n\n {\n \"Type of primary key\": \"<class 'int'>\",\n \"Value of primary key\": 9999999999999\n }\n\n* \\http://0.0.0.0:8080/integer/a352da04-c1af-4a44-8a94-c37f8f37b2bc\n ::\n\n 404: Not Found\n\n* \\http://0.0.0.0:8080/integer/abc\n ::\n\n 404: Not Found\n\n* \\http://0.0.0.0:8080/uuid/a352da04-c1af-4a44-8a94-c37f8f37b2bc\n\n .. code-block:: json\n\n {\n \"Type of primary key\": \"<class 'uuid.UUID'>\",\n \"Value of primary key\": \"a352da04-c1af-4a44-8a94-c37f8f37b2bc\"\n }\n\n* \\http://0.0.0.0:8080/uuid/13d1d0e0-4787-4feb-8684-b3da32609743\n\n .. code-block:: json\n\n {\n \"Type of primary key\": \"<class 'uuid.UUID'>\",\n \"Value of primary key\": \"13d1d0e0-4787-4feb-8684-b3da32609743\"\n }\n\n* \\http://0.0.0.0:8080/uuid/1\n ::\n\n 404: Not Found\n\n* \\http://0.0.0.0:8080/uuid/abc\n ::\n\n 404: Not Found\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Modest utility collection for development with AIOHTTP framework.",
"version": "1.1.0",
"project_urls": {
"Documentation": "https://aiohttp-things.readthedocs.io/",
"Homepage": "https://github.com/ri-gilfanov/aiohttp-things",
"Repository": "https://github.com/ri-gilfanov/aiohttp-things"
},
"split_keywords": [
"aiohttp",
" asyncio"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f96233ada42569a52ea1b8f1c0e930febe19fd84125a089866d72dac77434d9a",
"md5": "0e3c8c8cd846185e6bc033eaf7f56786",
"sha256": "2a71a9cb55c0bcc9a57331d7eff293910d2b0f9e2d60db75463e4b66779e73b0"
},
"downloads": -1,
"filename": "aiohttp_things-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0e3c8c8cd846185e6bc033eaf7f56786",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 5684,
"upload_time": "2024-12-06T03:32:36",
"upload_time_iso_8601": "2024-12-06T03:32:36.596169Z",
"url": "https://files.pythonhosted.org/packages/f9/62/33ada42569a52ea1b8f1c0e930febe19fd84125a089866d72dac77434d9a/aiohttp_things-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a46df90e1bbd843c148eca1be50cf83ee432630a1ddeb29dc62dd4f000da0a63",
"md5": "d29517af6e68eb64bc12e6732d69180d",
"sha256": "59b07455acb2e15d21b269a65642a74063f7421894de528fce1bcf3e49d0cc95"
},
"downloads": -1,
"filename": "aiohttp_things-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "d29517af6e68eb64bc12e6732d69180d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 5095,
"upload_time": "2024-12-06T03:32:38",
"upload_time_iso_8601": "2024-12-06T03:32:38.558837Z",
"url": "https://files.pythonhosted.org/packages/a4/6d/f90e1bbd843c148eca1be50cf83ee432630a1ddeb29dc62dd4f000da0a63/aiohttp_things-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-06 03:32:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ri-gilfanov",
"github_project": "aiohttp-things",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "aiohttp-things"
}