Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vrcmarcos/flask-paginated-response
Response maker for Flask with RFC Standards such as Link Headers
https://github.com/vrcmarcos/flask-paginated-response
Last synced: about 1 month ago
JSON representation
Response maker for Flask with RFC Standards such as Link Headers
- Host: GitHub
- URL: https://github.com/vrcmarcos/flask-paginated-response
- Owner: vrcmarcos
- License: mit
- Created: 2016-08-17T12:54:50.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-05-01T20:14:24.000Z (over 1 year ago)
- Last Synced: 2024-10-07T20:04:48.072Z (about 1 month ago)
- Language: Python
- Homepage: https://pypi.python.org/pypi/Flask-Paginated-Response
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flask Paginated Response
Response maker for Flask with RFC Standards such as Link Headers
[![Build Status](https://travis-ci.org/vrcmarcos/flask-paginated-response.svg?branch=master)](https://travis-ci.org/vrcmarcos/flask-paginated-response) [![Coverage Status](https://coveralls.io/repos/github/vrcmarcos/flask-paginated-response/badge.svg?branch=master)](https://coveralls.io/github/vrcmarcos/flask-paginated-response?branch=master) [![PyPI version](https://badge.fury.io/py/Flask-Paginated-Response.svg)](https://badge.fury.io/py/Flask-Paginated-Response) [![Code Health](https://landscape.io/github/vrcmarcos/flask-paginated-response/master/landscape.svg?style=flat)](https://landscape.io/github/vrcmarcos/flask-paginated-response/master) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/vrcmarcos/flask-paginated-response/master/LICENSE)
## Instalation
```bash
pip install Flask-Paginated-Response
```## Usage
To use Flask Paginated Response, build your response object with the *PaginatedResponse* class:
```python
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:
```bash
HTTP/1.0 200 OK
X-Total-Count: 18
Link: ; rel="last", ; 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