Esempio n. 1
0
    def add_athlete():
        # Add new athlete
        body = request.get_json()
        name = body.get('name', None)
        goal = body.get('goal', None)
        weight = body.get('weight', None)
        height = body.get('height', None)
        age = body.get('age', None)

        try:
            new_athlete = Athlete(
                name=name,
                goal=goal,
                weight=weight,
                height=height,
                age=age,
            )
            new_athlete.insert()

            return jsonify({'success': True, 'athlete': new_athlete.format()})
        except:
            abort(422)