Skip to main content

Asynchronous restful API

Project description

Asynchronous restful API

PyPI Travis build on master Travis build on develop Codecov coverage Chat on Gitter License

特色

✓ 基于aiohttp的异步web后端,实现了路由层和视图层

✓ 使用设计较友好

安装

pip install asyncweb

开始使用

“asyncweb”允许您在几个步骤中快速创建一个rest资源。 它自动在集合或单个项上创建资源路由;只需在方法上指定'_collection'或'_item'后缀即可。 使用python字典,结果/请求的序列化/反序列化是透明的。

使用案例

from aiohttp import web
from asyncweb import RestView, routes


@routes.resource("/views")
class RestResource(RestView):

    # example call: GET to <server>/views?start=10
    async def on_get_collection(self, start=0) -> list:
        return [
            {"id": int(start) + 1, "value": 1},
            {"id": int(start) + 2, "value": 2},
        ]

    # example call: GET <server>/views/80
    async def on_get_item(self, id: str) -> dict:
        return self.key

    # example call: POST to <server>/views
    async def on_post_collection(self, body: dict) -> dict:
        return body


app = web.Application()
app.add_routes(routes)
app['key'] = [1, 2, 4, 5]

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

asyncweb-0.0.2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file asyncweb-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: asyncweb-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.7.1

File hashes

Hashes for asyncweb-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 09c7e3a6159a426052523ff5df652c74c7d01e444db49c613ccda34d856058b7
MD5 4caaee5918e9248b7843149969f9bcaa
BLAKE2b-256 7b594528097f9fe4fe8306fd3a32b1f3f1686cf336df1c40091857c626d1c641

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page