Playing with Flask and just wanted to print some data in JSON format, but I keep getting the error:
NameError: global name "jsonify" not defined
from flask import Flask from flask import json app = Flask(__name__) @app.route("/") def testJSON(): x = "Test1" y = "Test2" return jsonify(a=x,z=y) if __name__ == "__main__": app.debug = True app.run()
Their documentation says that I either need to install Python 2.6 or simplejson - I have both.
Python 2.7.3:
sys.version '2.7.3 (default, May 9, 2012, 11:42:16 PM) \ n [GCC 4.4.3]'
simplejson:
root @Python: ~ / PythonScripts # pip install simplejson The requirement has already been met (use --upgrade to upgrade): simplejson in / usr / local / lib / python 2.7 / site-packages Cleaning up ...
source share