API: Fixed response in getUserByToken. returning JSON and not a string

This commit is contained in:
Sagi Dayan 2015-05-12 17:13:38 +03:00
parent 7e2d8914a7
commit 114bbdfe8b

View file

@ -6,7 +6,7 @@ from google.appengine.ext import db
import requests import requests
import uuid import uuid
from flask import Flask, request, render_template, redirect, abort from flask import Flask, request, render_template, redirect, abort, Response
from flask.ext.github import GitHub from flask.ext.github import GitHub
from flask.ext.cors import CORS, cross_origin from flask.ext.cors import CORS, cross_origin
@ -62,9 +62,14 @@ def getUserByToken(token):
query.filter("seToken = ", token) query.filter("seToken = ", token)
for u in query.run(limit=5): for u in query.run(limit=5):
return u.to_JSON() return Response(response=u.to_JSON(),
status=201,
mimetype="application/json") # Real response!
return Response(response=json.dumps({'message' : 'No User Found'}),
status=403,
mimetype="application/json")
return json.dumps({'message' : 'No User Found'}), 403
@app.route('/githubOAuth') @app.route('/githubOAuth')