Skip to content

vrcmarcos/flask-paginated-response

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

About

Response maker for Flask with RFC Standards such as Link Headers

Resources

License

Stars

Watchers

Forks

Packages

No packages published