input: Write a function to create a basic REST API using Python and Flask to list all the countries in the world. The API should listen for GET requests at the route '/countries', read a JSON file named 'data.json' containing the list of countries, and return the list as a JSON response. If the 'data.json' file is not found or invalid, it should return an appropriate error message.
  
  import flask
  from flask import Flask, request, jsonify
  import json
  
  app = Flask(__name__)
  
  @app.route('/countries', methods=['GET'])
  def get_countries():
      try:
          with open('data.json', 'r') as f:
              countries = json.load(f)
              return jsonify(countries)
      except FileNotFoundError:
          return jsonify({"error": "File 'data.json' not found"}), 404
      except json.JSONDecodeError:
          return jsonify({"error": "Invalid JSON in 'data.json'"}), 400
  
  if __name__ == '__main__':
      app.run()
  
  assert get_countries()['country1']== 'Afghanistan'
  assert get_countries()['country2']== 'Albania'
  assert get_countries()['country3']== 'Algeria'
  assert get_countries()['country4']== 'Andorra'
  assert get_countries()['country5']== 'Angola'
output: def get_countries():
      try:
          with open('data.json', 'r') as f:
              countries = json.load(f)
              return jsonify(countries)
      except FileNotFoundError:
          return jsonify({"error": "File 'data.json' not found"}), 404
      except json.JSONDecodeError:
          return jsonify({"error": "Invalid JSON in 'data.json'"}), 400