asoke-0.0.2
توضیحات
A simple class-based dispatcher for ASGI apps and a quickstart wrapper
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | asoke-0.0.2 |
| نام | asoke |
| نسخه کتابخانه | 0.0.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | AXY |
| ایمیل نویسنده | axy@declassed.art |
| آدرس صفحه اصلی | https://declassed.art/repository/asoke |
| آدرس اینترنتی | https://pypi.org/project/asoke/ |
| مجوز | - |
=====
Asoke
=====
Asoke is a simple class-based dispatcher for ASGI apps and a quickstart wrapper.
It is based on Hypercorn and Starlette.
Also it provides `quickstart` wrapper for ease of use.
Example:
.. code:: python
from asoke import expose, quickstart
from starlette.requests import Request
from starlette.responses import JSONResponse
class Items:
@expose(methods='GET')
async def get(self, request):
items = []
# get items somehow
return JSONResponse(dict(status='success', items=items))
@expose
async def put(self, request):
item = await request.json()
# put item somehow
return JSONResponse(dict(status='success'))
class Entities:
@expose(methods='GET')
async def get(self, request):
entities = []
# get entities somehow
return JSONResponse(dict(status='success', entities=entities))
@expose
async def put(self, request):
entity = await request.json()
# put entity somehow
return JSONResponse(dict(status='success'))
class Api:
items = Items()
entities = Entities()
if __name__ == "__main__":
quickstart(
Api(),
{
'bind': ['127.0.0.1:12345']
'alpn_protocols': ['h2']
},
base_uri = '/api'
)
See also: https://declassed.art/en/blog/2022/07/06/asoke
نیازمندی
| مقدار | نام |
|---|---|
| - | hypercorn |
| - | starlette |
| - | uvloop |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl asoke-0.0.2:
pip install asoke-0.0.2.whl
نصب پکیج tar.gz asoke-0.0.2:
pip install asoke-0.0.2.tar.gz