input: Write a function named `fetch_data_as_json` that creates a Flask API endpoint to fetch data from an SQL database and return the data as JSON. The function should return a JSON object containing all rows from the 'users' table in the database. If the function is executed, it should start the Flask application in debug mode.
  
  py
  import json 
  import sqlite3
  from flask import Flask, request, jsonify 
  
  app = Flask(__name__) 
    
  def dict_factory(cursor, row):
      d = {}
      for idx, col in enumerate(cursor.description):
          d[col[0]] = row[idx]
      return d 
    
  @app.route('/', methods=['GET'])
  def index(): 
      connection = sqlite3.connect('database.db')
      connection.row_factory = dict_factory
      cur = connection.cursor() 
      all_users = cur.execute('SELECT * FROM users;').fetchall() 
      return jsonify(all_users) 
    
  if __name__ == '__main__': 
      app.run(debug = True)
  
  
  assert fetch_data_as_json().get('http://127.0.0.1:5000/')==[{'id': 1, 'name': 'Alice', 'email': 'alice@example.com'}, {'id': 2, 'name': 'Bob', 'email': 'bob@example.com'}]
output: 
  def fetch_data_as_json():
      app = Flask(__name__)
  
      def dict_factory(cursor, row):
          d = {}
          for idx, col in enumerate(cursor.description):
              d[col[0]] = row[idx]
          return d
  
      @app.route('/', methods=['GET'])
      def index():
          connection = sqlite3.connect('database.db')
          connection.row_factory = dict_factory
          cur = connection.cursor()
          all_users = cur.execute('SELECT * FROM users;').fetchall()
          return jsonify(all_users)
  
      if __name__ == '__main__':
          app.run(debug=True)
  