==============
aiohttp-things
==============
|ReadTheDocs| |PyPI release| |License| |Python versions| |PyPI downloads| |GitHub CI| |Codecov|
.. |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.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-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
.. |Codecov| image:: https://codecov.io/gh/ri-gilfanov/aiohttp-things/branch/master/graph/badge.svg
:target: https://codecov.io/gh/ri-gilfanov/aiohttp-things
:alt: codecov.io status for master branch
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.8",
"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/06/ee/58dc0c92276cee2dfc959e7b593691ad19bc7d9d84b51555ed11d4b2e293/aiohttp_things-1.0.0.tar.gz",
"platform": null,
"description": "==============\naiohttp-things\n==============\n|ReadTheDocs| |PyPI release| |License| |Python versions| |PyPI downloads| |GitHub CI| |Codecov|\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.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-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\n.. |Codecov| image:: https://codecov.io/gh/ri-gilfanov/aiohttp-things/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/ri-gilfanov/aiohttp-things\n :alt: codecov.io status for master branch\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.0.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": "05b01090a0f55d723ffa3de634baed25d3fc23a3f8615be5f0f172d1b7b1f60c",
"md5": "5eb878b1aede77ded7b1678d91f49acf",
"sha256": "dab325f5d5b9d286ca4a3b1243f963d50e623142c6aa0e819d5b9a0f70a9dc17"
},
"downloads": -1,
"filename": "aiohttp_things-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5eb878b1aede77ded7b1678d91f49acf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 5833,
"upload_time": "2024-09-15T04:26:14",
"upload_time_iso_8601": "2024-09-15T04:26:14.200879Z",
"url": "https://files.pythonhosted.org/packages/05/b0/1090a0f55d723ffa3de634baed25d3fc23a3f8615be5f0f172d1b7b1f60c/aiohttp_things-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "06ee58dc0c92276cee2dfc959e7b593691ad19bc7d9d84b51555ed11d4b2e293",
"md5": "093853b53b2c105223d2077461b49ebd",
"sha256": "75af32b77b51257e2f107527bafc2ad00c394ad65375c01c1c2001f304745f59"
},
"downloads": -1,
"filename": "aiohttp_things-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "093853b53b2c105223d2077461b49ebd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 5200,
"upload_time": "2024-09-15T04:26:15",
"upload_time_iso_8601": "2024-09-15T04:26:15.482627Z",
"url": "https://files.pythonhosted.org/packages/06/ee/58dc0c92276cee2dfc959e7b593691ad19bc7d9d84b51555ed11d4b2e293/aiohttp_things-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-15 04:26:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ri-gilfanov",
"github_project": "aiohttp-things",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"lcname": "aiohttp-things"
}