Permalink
Browse files

Changed mimetype return for callback to application/javascript

  • Loading branch information...
ejamesc committed Feb 19, 2012
1 parent dcde8b1 commit 2a5d031b67d2bfe13a2726432d200f5610a1ce3d
Showing with 9 additions and 8 deletions.
  1. +9 −8 corsapi.py
View
@@ -12,19 +12,20 @@
app = Flask(__name__)
-def js_response_helper(dataJson, mime):
+def js_response_helper(data_json, mime):
"""Assumes that callback is last arg.
"""
res = ""
url = request.url
- cb = re.compile('callback=([^&]*)')
- la = cb.search(url)
- if la:
- res = la.expand("\g<1>")
- res = res + "(" + dataJson + ");"
+ cb_reg = re.compile('callback=([^&]*)')
+ cb = cb_reg.search(url)
+ if cb:
+ res = cb.expand("\g<1>")
+ res = res + "(" + data_json + ");"
+ return Response(res, mimetype='application/javascript')
else:
- res = dataJson
- return Response(res, mimetype=mime)
+ res = data_json
+ return Response(res, mimetype=mime)
# mongoDB connection

0 comments on commit 2a5d031

Please sign in to comment.