input: Write a function to create a REST API using Flask and SQLAlchemy that allows users to perform CRUD operations on a database. The function should set up the Flask app, configure the database, define a model for records, and implement endpoints for creating, reading, updating, and deleting records. If the function is successful in setting up the API, it returns True, otherwise it returns False.
  assert create_api()==True
output: def create_api():
      from flask import Flask, request, jsonify
      from flask_sqlalchemy import SQLAlchemy
  
      app = Flask(__name__)
      app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///records.db'
      db = SQLAlchemy(app)
  
      class Record(db.Model):
          id = db.Column(db.Integer, primary_key=True)
          name = db.Column(db.String(80), nullable=False)
          value = db.Column(db.Float, nullable=False)
  
          def to_dict(self):
              return {'id': self.id, 'name': self.name, 'value': self.value}
  
      @app.route('/records', methods=['POST'])
      def create_record():
          data = request.get_json()
          new_record = Record(name=data['name'], value=data['value'])
          db.session.add(new_record)
          db.session.commit()
          return jsonify(new_record.to_dict()), 201
  
      @app.route('/records', methods=['GET'])
      def get_records():
          records = Record.query.all()
          return jsonify([record.to_dict() for record in records])
  
      @app.route('/records/<int:id>', methods=['GET'])
      def get_record(id):
          record = Record.query.get(id)
          if record:
              return jsonify(record.to_dict())
          return jsonify({'message': 'Record not found'}), 404
  
      @app.route('/records/<int:id>', methods=['PUT'])
      def update_record(id):
          record = Record.query.get(id)
          if record:
              data = request.get_json()
              record.name = data['name']
              record.value = data['value']
              db.session.commit()
              return jsonify(record.to_dict())
          return jsonify({'message': 'Record not found'}), 404
  
      @app.route('/records/<int:id>', methods=['DELETE'])
      def delete_record(id):
          record = Record.query.get(id)
          if record:
              db.session.delete(record)
              db.session.commit()
              return jsonify({'message': 'Record deleted'})
          return jsonify({'message': 'Record not found'}), 404
  
      try:
          db.create_all()
          app.run(debug=True)
          return True
      except Exception as e:
          print(e)
          return False