Flask-Filtered-Response

Add filter capability to JSON responses


License
MIT
Install
pip install Flask-Filtered-Response==1.0.0

Documentation

Flask Filtered Response

Add filter capability to JSON responses

Build Status Coverage Status PyPI version Code Health GitHub license

Instalation

pip install Flask-Filtered-Response

Usage

To use Flask Filtered Response, decorate your view with @filtered decorator:

import json
from flask_filtered_response import filtered

@app.route('/filtered/single_node')
@filtered
def single_node():
    response_dict = {
        'test_int': 123,
        'test_string': 'Hey!',
    }
    return Response(json.dumps(response_dict))

Using @filtered decorator, you will enable the ability to use the query string fields:

  • Request:

    curl -X GET http://localhost:5000/filtered/single_node?fields=test_int
  • Response:

    {
        "test_int": 123
    }

You can filter for multiple fields using , (comma). Nested fields filtering is currently NOT supported.

Changelog

1.0.2:

  • @filtered: Fixed when response data is None or Empty

1.0.1:

  • setup.py: Fixed description and URL

1.0.0:

  • @filtered: Created @filtered decorator