Skip to content

vrcmarcos/flask-paginated-response

Folders and files

NameName
Last commit message
Last commit date
Aug 19, 2016
Aug 19, 2016
Aug 17, 2016
Aug 17, 2016
Aug 17, 2016
Aug 17, 2016
Aug 19, 2016
Nov 4, 2019
Aug 17, 2016
Aug 17, 2016
Aug 19, 2016

Repository files navigation

Flask Paginated Response

Response maker for Flask with RFC Standards such as Link Headers

Build Status Coverage Status PyPI version Code Health GitHub license

Instalation

pip install Flask-Paginated-Response

Usage

To use Flask Paginated Response, build your response object with the PaginatedResponse class:

import json
from flask_paginated_response import PaginatedResponse

@app.route('/')
def index(self):
	per_page = 10
    current_page = 0
    total = 18
    response = {'status': 'online'}
	return PaginatedResponse(per_page, current_page, total, json.dumps(response))

Using PaginatedResponse class, you will get this response headers:

HTTP/1.0 200 OK
X-Total-Count: 18
Link: <http://localhost:5000/?size=3&page=5>; rel="last", <http://localhost:5000/?size=3&page=1>; rel="next"
Content-Type: application/json
Content-Length: 515
Server: Werkzeug/0.11.10 Python/2.7.10
Date: Thu, 21 Jul 2016 14:08:23 GMT

Changelog

1.0.1:

  • PaginatedResponse: Extending the full Response __init__ method with all available kwargs

1.0.0:

  • PaginatedResponse: Created PaginatedResponse class