示例#1
0
def user_create():
    errors = {}
    us = UserService()
    if request.method == 'POST':
        print request.form
        try:
            u = us.create(**request.form)
            if u:
                return jsonify(u.tojson())
        except:
            return abort(500)
    else:
        return abort(401)
示例#2
0
def user_login():
    errors = {}
    us = UserService()
    if request.method == 'POST':
        try:
            user = us.by_username(request.form['username'])
            if user.valid_password(request.form['password']):
                return jsonify(user)
            else:
                return abort(401)
        except:
            return abort(500)
    else:
        return abort(400)