input: Write a function to create a Flask-based web application for a car insurance calculator. The application should include a route '/calculate' that accepts POST requests with user input data (age, gender, car_model) and returns a calculated insurance price in JSON format. If the provided input data is valid, the function should return the calculated insurance price; otherwise, it should return an appropriate error message.
  assert calculate([{'age': 25, 'gender': 'male', 'car_model': 'Toyota'}])=={'insurance_price': 500.00}
  assert calculate([{'age': 17, 'gender': 'female', 'car_model': 'Ford'}])=={'insurance_price': 700.00}
  assert calculate([{'age': 30, 'gender': 'male', 'car_model': 'BMW'}])=={'insurance_price': 1000.00}
  assert calculate([{'age': 45, 'gender': 'female', 'car_model': 'Honda'}])=={'insurance_price': 600.00}
  assert calculate([{'age': 20, 'gender': 'other', 'car_model': 'Audi'}])=={'insurance_price': 800.00}
output: 
  @app.route('/calculate', methods=['POST'])
  def calculate():
      data = request.get_json()
      if not data or 'age' not in data or 'gender' not in data or 'car_model' not in data:
          return jsonify({'error': 'Invalid input data'}), 400
      
      age = data['age']
      gender = data['gender']
      car_model = data['car_model']
      
      if age < 18:
          return jsonify({'error': 'Age must be 18 or older'}), 400
      
      if gender not in ['male', 'female', 'other']:
          return jsonify({'error': 'Invalid gender'}), 400
      
      if car_model not in ['Toyota', 'Ford', 'BMW', 'Honda', 'Audi']:
          return jsonify({'error': 'Invalid car model'}), 400
      
      base_price = 500.00
      if age < 25:
          base_price += 200.00
      if gender == 'female':
          base_price += 100.00
      if car_model in ['BMW', 'Audi']:
          base_price += 500.00
      
      return jsonify({'insurance_price': base_price})
  