input: 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)
output:     
  @app.route('/user/<int:user_id>', methods=['GET'])
  def get_user(user_id):
      connection = sqlite3.connect('database.db')
      connection.row_factory = dict_factory
      cur = connection.cursor()
      user = cur.execute('SELECT * FROM users WHERE id = ?;', (user_id,)).fetchone()
      if user:
          return jsonify(user)
      else:
          return jsonify({'error': 'User not found'}), 404
  
  @app.route('/user', methods=['POST'])
  def add_user():
      data = request.get_json()
      if not data or 'name' not in data or 'email' not in data:
          return jsonify({'error': 'Invalid data'}), 400
      
      connection = sqlite3.connect('database.db')
      cur = connection.cursor()
      cur.execute('INSERT INTO users (name, email) VALUES (?, ?);', (data['name'], data['email']))
      connection.commit()
      new_user_id = cur.lastrowid
      return jsonify({'id': new_user_id, 'name': data['name'], 'email': data['email']}), 201
  
  @app.route('/user/<int:user_id>', methods=['PUT'])
  def update_user(user_id):
      data = request.get_json()
      if not data or 'name' not in data or 'email' not in data:
          return jsonify({'error': 'Invalid data'}), 400
      
      connection = sqlite3.connect('database.db')
      cur = connection.cursor()
      cur.execute('UPDATE users SET name = ?, email = ? WHERE id = ?;', (data['name'], data['email'], user_id))
      connection.commit()
      return jsonify({'id': user_id, 'name': data['name'], 'email': data['email']})
  
  @app.route('/user/<int:user_id>', methods=['DELETE'])
  def delete_user(user_id):
      connection = sqlite3.connect('database.db')
      cur = connection.cursor()
      cur.execute('DELETE FROM users WHERE id = ?;', (user_id,))
      connection.commit()
      return jsonify({'result': 'User deleted'})
  