October 2018
Intermediate to advanced
332 pages
8h 9m
English
The output format is defined by creating a dictionary of field objects that represent basic types. The key of the field defines what attribute the field will try to translate. By passing the dictionary to the marshal_with decorator, any object that the get method attempts to return will be first translated using the dictionary. This also works for lists of objects. Let's look at a simple way of implementing this API endpoint. The following example code takes pagination into account, but we will show you how this works later.
Look at the following api/blog/controllers.py file:
import datetimefrom flask import abortfrom flask_restful import Resource, fields, marshal_withfrom flask_jwt_extended import jwt_required, get_jwt_identity ...