94474/how-to-return-json-response-from-flask-view
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 return a JSON response?
@app.route("/summary") def summary(): d = make_summary() # send it back as json
Hello,
Pass the summary data to the jsonify function, which returns a JSON response.
from flask import jsonify @app.route('/summary') def summary(): d = make_summary() return jsonify(d)
response.setContentType("application/json"); // Get the printwriter object from response ...READ MORE
In the event the method you're calling ...READ MORE
I want to maintain a book library. ...READ MORE
Scanner Class is used to take input ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
You can simply the built-in function in ...READ MORE
Hello @kartik, Implement your class with Serializable. Let's ...READ MORE
Hello @kartik, In case your Java class is ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.