Пример #1
0
def getIdByUsername():
    print(request.args)
    if request.method == "GET":
        print(Handler().getIdByUsername(request.args).data)
        return Handler().getIdByUsername(request.args)
    else:
        return jsonify(Error="Method not allowed."), 405
Пример #2
0
def getAllUsers():
    if request.method == 'POST':
        print("REQUEST: ", request.json)
        return Handler().insertUser(request.json)
    else:
        if not request.args:
            return Handler().getAllUsers()
        else:
            return Handler().getUserByIdORUsername(request.args)
Пример #3
0
def getContactById():
    if request.method == 'GET':
        return Handler().getContactsById(request.args.to_dict())
    elif request.method == 'POST':
        return Handler().addToContactList(request.args.to_dict(), request.json)
    elif request.method == 'DELETE':  # NOT YET!!!
        return Handler().deleteContact(request.args.to_dict(), request.json)
    else:
        return jsonify(Error="Method not allowed."), 405
Пример #4
0
def getUserById(uid):
    print(uid)
    if request.method == 'GET':
        return Handler().getUserById(uid)
    elif request.method == 'PUT':
        return Handler().updateUser(
            uid, request.json)  # update needs to be implemented
    elif request.method == 'DELETE':
        return Handler().deleteUser(uid)
    else:
        return jsonify(Error="Method not allowed."), 405
Пример #5
0
def getAllContactsFromUser(uid):
    if request.method == 'GET':
        return Handler().getContactsById(uid)
    elif request.method == 'POST':
        return Handler().addToContactList(uid, request.json)
    elif request.method == 'DELETE':
        if not request.json:
            return jsonify(
                Error="Need to specify parameters for deletion"), 405
        else:
            return Handler().deleteContact(uid, request.json)
    else:
        return jsonify(Error="Method not allowed."), 405
Пример #6
0
def deleteContactFromUser(uid, cid):
    if request.method == 'DELETE':
        form = {}
        form['cid'] = cid
        return Handler().deleteContact(uid, (form))
    else:
        return jsonify(Error="Method not allowed."), 405
Пример #7
0
def register_user():
    if request.method == 'POST':
        return Handler().insertUser(request.json)
Пример #8
0
def validate_login():
    if request.method == 'POST':
        print(request.json)
        print(Handler().validate_login(request.json))
        return Handler().validate_login(request.json)