To return the results as a response from a Flask view you can pass the summary data to the jsonify function, which returns a JSON response.
jsonify():-
This function turns the JSON output into a response object with the application/json mime type. For users convenience, it also converts multiple arguments into an array or multiple keyword arguments into a dictionary. So, it means that if we do jsonify(1,2,3) and jsonify([1,2,3]) both are serialize as [1,2,3]. For that, you will write the following piece of code.
from flask import jsonify
@app.route('/summary')
def summary():
d = make_summary()
return jsonify(d)
If you wish to learn more about Python, visit Python tutorial and Python course by Intellipaat.