Пример #1
0
Файл: api.py Проект: beylsp/auch
def edit_user():
    if not request.get_json():
        return err.make_error(400, "Missing json body")

    data, errors = user_schema.load(request.json)
    if errors:
        return err.make_error(400, "Invalid json body")

    User.query.filter_by(username=g.user.username).update(data)
    db.session.commit()
    return make_response(jsonify({'id': g.user.id}), 200)
Пример #2
0
Файл: api.py Проект: beylsp/auch
def edit_user():
    if not request.get_json():
        return err.make_error(400, "Missing json body")

    data, errors = user_schema.load(request.json)
    if errors:
        return err.make_error(400, "Invalid json body")

    User.query.filter_by(username = g.user.username).update(data)
    db.session.commit()
    return make_response(jsonify({'id': g.user.id}), 200)
Пример #3
0
Файл: api.py Проект: beylsp/auch
def new_user():
    if not request.get_json():
        return err.make_error(400, "Missing json body")

    data, errors = user_schema.load(request.json)
    if errors:
        return err.make_error(400, "Invalid json body")

    user = User(username=data.get('username'))
    user.password = data.get('password')
    db.session.add(user)
    db.session.commit()
    return make_response(jsonify({'id': user.id}), 201)
Пример #4
0
Файл: api.py Проект: beylsp/auch
def new_user():
    if not request.get_json():
        return err.make_error(400, "Missing json body")

    data, errors = user_schema.load(request.json)
    if errors:
        return err.make_error(400, "Invalid json body")

    user = User(username = data.get('username'))
    user.password = data.get('password')
    db.session.add(user)
    db.session.commit()
    return make_response(jsonify({'id': user.id}), 201)