Summary
This chapter has proven to us that some components apply to both API-based and web-based applications, but there are specific components that fit better in API transactions than in web-based ones. It provided details on Flask’s JSON de-serialization applied to request bodies and serialization of outgoing objects to be part of the API responses. The many options of capturing the request body through request.json
, request.data
, and request.get_json()
and generating responses through its jsonify()
or make_response()
and Response
class with application/json
as a mime-type show Flask’s flexibility as a framework.
The chapter also showcased Flask’s ability to adapt to different third-party JSON providers through sub-classing its JSONProvider
class. Moreover, the many options for providing our API endpoints with route filtering mechanisms also show that the platform can manage the application’s incoming requests and outgoing responses like any good framework...