input: Write a function to create a Flask API that connects to an SQL database, fetches the users table data, and returns it as a JSON response. The function should use the given database connection and return the JSONified data of all users from the table.
  
  
  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)
  
  assert index().get_json() == [{'id': 1, 'name': 'John Doe'}, {'id': 2, 'name': 'Jane Doe'}], "Should return JSON data of users"
output: 
  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)
  