Fixed the letter case of the javascript file names.

Also, JSON data should be returned to the client using an
application/json MIME-TYPE using flask's jsonify function.
This commit is contained in:
Ronan Dunklau
2015-06-29 12:12:27 +05:30
committed by Ashesh Vashi
parent 751f8383fa
commit 9e0b011ec8
8 changed files with 144 additions and 161 deletions

View File

@@ -9,20 +9,13 @@
"""Utility functions for dealing with AJAX."""
from flask import Response
from flask import jsonify
import json
def make_json_response(success=1, errormsg='', info='', result={}, data={}):
def make_json_response(success=True, **kwargs):
"""Create a HTML response document describing the results of a request and
containing the data."""
doc = { }
doc['success'] = success
doc['errormsg'] = errormsg
doc['info'] = info
doc['result'] = result
doc['data'] = data
response = Response(response=json.dumps(doc),
status=200,
mimetype="text/json")
return response
response = kwargs.copy()
response.setdefault('result', {})
response.setdefault('data', {})
return jsonify(response)