input: Write a function to create a Python API that fetches data from an SQL database and presents the data in the form of JSON. The function should return a Flask application that includes a route to fetch all users from the 'users' table in the database and display them as JSON. If the database connection or query fails, the function should handle the exception gracefully and return an appropriate HTTP status code.
  assert create_api()
  # Output will be None as the function returns a Flask application instance, not a boolean or other specific value.
output: def create_api():
      from flask import Flask, jsonify
      import sqlite3
  
      app = Flask(__name__)
  
      @app.route('/users', methods=['GET'])
      def get_users():
          try:
              conn = sqlite3.connect('database.db')
              cursor = conn.cursor()
              cursor.execute("SELECT * FROM users")
              rows = cursor.fetchall()
              users = [dict(zip([column[0] for column in cursor.description], row)) for row in rows]
              return jsonify(users)
          except sqlite3.Error as e:
              return jsonify({"error": str(e)}), 500
          finally:
              if conn:
                  conn.close()
  
      return app