input: Write a function to create a Flask API that fetches data from an SQLite database and returns it in JSON format. The function should define a dictionary factory to convert query results into dictionaries and expose an endpoint that returns all records from the 'users' table. If the database is empty, the function should return an empty list in JSON format.
  assert index()==jsonify([])
  assert index()==jsonify([{'id': 1, 'name': 'Alice'}, {'id': 2, 'name': 'Bob'}])
  assert index()==jsonify([{'id': 3, 'name': 'Charlie'}, {'id': 4, 'name': 'David'}])
  assert index()==jsonify([{'id': 5, 'name': 'Eve'}])
  assert index()==jsonify([])
output: 
  def index():
      def dict_factory(cursor, row):
          d = {}
          for idx, col in enumerate(cursor.description):
              d[col[0]] = row[idx]
          return d
  
      conn = sqlite3.connect('database.db')
      conn.row_factory = dict_factory
      c = conn.cursor()
      c.execute("SELECT * FROM users")
      users = c.fetchall()
      conn.close()
      return jsonify(users)
  