input: Write a function to implement a REST API with Python and Flask that allows users to create, read, update, and delete records from a database. The function should create an API that supports the following operations: GET to retrieve all records, POST to create a new record, PUT to update an existing record, and DELETE to remove a record. If the API is set up correctly, return True; otherwise, return False.
  assert setup_rest_api()==True
output: 
  def setup_rest_api():
      from flask import Flask, request, jsonify
      import sqlite3
  
      app = Flask(__name__)
      db_path = 'records.db'
  
      def get_db_connection():
          conn = sqlite3.connect(db_path)
          conn.row_factory = sqlite3.Row
          return conn
  
      @app.route('/records', methods=['GET'])
      def get_records():
          conn = get_db_connection()
          records = conn.execute('SELECT * FROM records').fetchall()
          conn.close()
          return jsonify([dict(record) for record in records])
  
      @app.route('/records', methods=['POST'])
      def create_record():
          data = request.get_json()
          conn = get_db_connection()
          conn.execute('INSERT INTO records (name, value) VALUES (?, ?)',
                       (data['name'], data['value']))
          conn.commit()
          conn.close()
          return jsonify({'message': 'Record created successfully'}), 201
  
      @app.route('/records/<int:id>', methods=['PUT'])
      def update_record(id):
          data = request.get_json()
          conn = get_db_connection()
          conn.execute('UPDATE records SET name = ?, value = ? WHERE id = ?',
                       (data['name'], data['value'], id))
          conn.commit()
          conn.close()
          return jsonify({'message': 'Record updated successfully'})
  
      @app.route('/records/<int:id>', methods=['DELETE'])
      def delete_record(id):
          conn = get_db_connection()
          conn.execute('DELETE FROM records WHERE id = ?', (id,))
          conn.commit()
          conn.close()
          return jsonify({'message': 'Record deleted successfully'})
  
      try:
          conn = sqlite3.connect(db_path)
          conn.execute('''CREATE TABLE IF NOT EXISTS records
                          (id INTEGER PRIMARY KEY AUTOINCREMENT,
                          name TEXT NOT NULL,
                          value TEXT NOT NULL)''')
          conn.close()
          app.run(port=5000, debug=False)
          return True
      except Exception as e:
          return False
  