示例#1
0
 def post(self):
     requests = JsonUtil.stringToCollection(request.data)
     try:
         email = requests['email']
         password = requests['password']
         print 'email: {0}, password: {1}'.format(email, password)
         user = User.query.filter(User.email == email).first()
         if user is not None and user.password == password :
             return Response(JsonUtil.objectToJson(user), mimetype='application/json')
         else:
             return {'flash':'Invalid email and password'}, 403
 
     except Exception as e:
         print e
         return 'Database error', 500
示例#2
0
 def get(self):
     try:
         builds = Build.query.all()
         return Response(JsonUtil.listToJson(builds), mimetype='application/json')
     except Exception as e:
         print e
         return '', 500
示例#3
0
 def get(self):
     print "calling /api/users/get"
     try:
         users = User.query.all()
         return Response(JsonUtil.listToJson(users), mimetype='application/json')
         
     except Exception as e:
         print e
         return '', 500
示例#4
0
    def post(self):
        build = json.loads(request.data, object_hook=Build.decode)
        try:
            db_session.add(build)
            db_session.commit()
        except Exception as e:
            print e
        return JsonUtil.objectToJson(build), 201
#         return '', 201
示例#5
0
    def get(self):
        print "calling /api/users/get"
        try:
            users = User.query.all()
            return Response(JsonUtil.listToJson(users),
                            mimetype='application/json')

        except Exception as e:
            print e
            return '', 500
示例#6
0
    def put(self, oid):
        build = json.loads(request.data, object_hook=Build.decode)

        try:
            build = db_session.merge(build)
            db_session.commit()
        except Exception as e:
           #TODO: log exception
           print e
        return JsonUtil.objectToJson(build), 201
示例#7
0
 def get(self, oid):
     build = Build.query.filter(Build.id == oid).first()
     return Response(JsonUtil.objectToJson(build), mimetype='application/json')
示例#8
0
    def test_(self):
        line1 = '{"email":"*****@*****.**","password":"******"}'
        line2 = '{email:[email protected],password:passwd}'
        print JsonUtil.stringToCollection(line1)
#         print JsonUtil.stringToCollection(line2)