I have a function that analyzes a CSV file with Pandas and produces a dict with summary information. I want to return the results as a response from a Flask view. How do I r
""" Using Flask Class-base View """
from flask import Flask, request, jsonify
from flask.views import MethodView
app = Flask(**__name__**)
app.add_url_rule('/summary/', view_func=Summary.as_view('summary'))
class Summary(MethodView):
def __init__(self):
self.response = dict()
def get(self):
self.response['summary'] = make_summary() # make_summary is a method to calculate the summary.
return jsonify(self.response)