Exemplo n.º 1
0
def regist():
    if request.method == 'POST':
        data = request.get_json()
        username = data.get('username')
        userid = data.get('userid')
        password = data.get('password')
        birthdate = data.get('birthdate')

        if not (userid and username and password):
            return jsonify({'error': 'No arguments'}), 400

        user = UserModel()
        user.id = userid
        user.name = username
        user.birthdate = birthdate
        user.password = password

        db.session.add(user)
        db.session.commit()
        return jsonify(), 201