input: Write a function to generate a REST API with Python and Flask that allows users to create, read, update, and delete records from a database. This function should set up an SQLite database, define a Record model, and implement routes to handle CRUD operations on records. The function should return the Flask app object for further use.
  assert generate_flask_app() != None
  assert generate_flask_app().config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:////tmp/test.db'
  assert hasattr(generate_flask_app(), 'get_records')
  assert hasattr(generate_flask_app(), 'create_record')
  assert hasattr(generate_flask_app(), 'update_record')
  assert hasattr(generate_flask_app(), 'delete_record')
output: 
  from flask import Flask, request, jsonify
  from flask_sqlalchemy import SQLAlchemy
  
  def generate_flask_app():
      app = Flask(__name__)
      app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
      app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
      db = SQLAlchemy(app)
  
      class Record(db.Model):
          id = db.Column(db.Integer, primary_key=True)
          data = db.Column(db.String(200), nullable=False)
  
      db.create_all()
  
      @app.route('/records', methods=['GET'])
      def get_records():
          records = Record.query.all()
          return jsonify([{'id': record.id, 'data': record.data} for record in records])
  
      @app.route('/records', methods=['POST'])
      def create_record():
          data = request.json.get('data')
          if not data:
              return jsonify({'error': 'Data is required'}), 400
          new_record = Record(data=data)
          db.session.add(new_record)
          db.session.commit()
          return jsonify({'id': new_record.id, 'data': new_record.data}), 201
  
      @app.route('/records/<int:id>', methods=['PUT'])
      def update_record(id):
          record = Record.query.get(id)
          if not record:
              return jsonify({'error': 'Record not found'}), 404
          data = request.json.get('data')
          if not data:
              return jsonify({'error': 'Data is required'}), 400
          record.data = data
          db.session.commit()
          return jsonify({'id': record.id, 'data': record.data})
  
      @app.route('/records/<int:id>', methods=['DELETE'])
      def delete_record(id):
          record = Record.query.get(id)
          if not record:
              return jsonify({'error': 'Record not found'}), 404
          db.session.delete(record)
          db.session.commit()
          return jsonify({'result': 'Record deleted'})
  
      return app
  