用于aiohttp.web应用程序的便捷实用工具。
aiohttp-utils的Python项目详细描述
aiohttp实用程序为构建aiohttp.web应用程序提供了方便的实用程序。
- 基于方法的处理程序(“资源”)
- 路由实用程序
- 默认情况下,使用json呈现进行内容协商
所有内容都是可选的。您可以根据需要尽可能多(或少)使用此工具包。
fromaiohttpimportwebfromaiohttp_utilsimportResponse,routing,negotiationapp=web.Application(router=routing.ResourceRouter())# Method-based handlersclassHelloResource:asyncdefget(self,request):name=request.GET.get('name','World')returnResponse({'message':'Hello '+name})app.router.add_resource_object('/',HelloResource())# Content negotiationnegotiation.setup(app,renderers={'application/json':negotiation.render_json})
安装
$ pip install aiohttp_utils
文档
完整的文档可在https://aiohttp-utils.readthedocs.io/获得。
项目链接
许可证
麻省理工学院许可。有关详细信息,请参见捆绑的LICENSE文件。