api之星的分页工具。
apistar-pagination的Python项目详细描述
API星形分页
- 版本:0.4.0
- 状态:生产/稳定
- 作者:joséantonio perdiguero lópez
api之星的分页工具。
功能
- 页码分页。
- 限制偏移分页。
快速启动
安装API星形分页:
pip install apistar-pagination
在视图中使用分页响应:
页码分页
fromapistar_paginationimportPageNumberResponsedefpage_number(page:http.QueryParam,page_size:http.QueryParam)->typing.List[int]:collection=range(10)# Get your whole collection instead of a list of numbersreturnPageNumberResponse(page=page,page_size=page_size,content=collection)
限制偏移分页
fromapistar_paginationimportLimitOffsetResponsedeflimit_offset(offset:http.QueryParam,limit:http.QueryParam)->typing.List[int]:collection=range(10)# Get your whole collection instead of a list of numbersreturnLimitOffsetResponse(offset=offset,limit=limit,content=collection)