flask api
@app.route('/api/v1/users', methods=['GET'])
def get_users():
users = [ user.json() for user in User.query.all() ]
return jsonify({'users': users })
@app.route('/api/v1/users/<id>', methods=['GET'])
def get_user(id):
user = User.query.filter_by(id=id).first()
if user is None:
return jsonify({'message': 'User does not exists'}), 404
return jsonify({'user': user.json() })