Closed Francmho closed 1 month ago
RELACION: Uno a muchos con usuario.
EJEMPLO:
@api.route('/workout-plans', methods=['POST']) def create_workout_plan(): data = request.json new_workout_plan = Workout_plan(Sets=data['Sets'], Reps=data['Reps'], Rest_time=data['Rest_time'], training_day=data['training_day'], SuperSet=data['SuperSet'], id=data['id'], Id_member=data['Id_member'], Id_exercise=data['Id_exercise'], Id_musclegroup=data['Id_musclegroup'])
try: db.session.add(new_workout_plan) db.session.commit() return jsonify({"message": "Workout plan created successfully", "workout_id": new_workout_plan.Id_workout}), 201 except IntegrityError: db.session.rollback() raise APIException('Error creating workout plan', status_code=400)
DOCUMENTACIÓN: https://flask-sqlalchemy.palletsprojects.com/en/2.x/quickstart/#installation
CRITERIOS DE VALIDACIÓN
RELACION: Uno a muchos con usuario.
EJEMPLO:
Endpoint para crear un nuevo plan de entrenamiento
@api.route('/workout-plans', methods=['POST']) def create_workout_plan(): data = request.json new_workout_plan = Workout_plan(Sets=data['Sets'], Reps=data['Reps'], Rest_time=data['Rest_time'], training_day=data['training_day'], SuperSet=data['SuperSet'], id=data['id'], Id_member=data['Id_member'], Id_exercise=data['Id_exercise'], Id_musclegroup=data['Id_musclegroup'])
DOCUMENTACIÓN: https://flask-sqlalchemy.palletsprojects.com/en/2.x/quickstart/#installation