code: def do_ocrmypdf(file):
      uploaddir = TemporaryDirectory(prefix="ocrmypdf-upload")
      downloaddir = TemporaryDirectory(prefix="ocrmypdf-download")
  
      filename = secure_filename(file.filename)
      up_file = os.path.join(uploaddir.name, filename)
      file.save(up_file)
  
      down_file = os.path.join(downloaddir.name, filename)
  
      cmd_args = [arg for arg in shlex.split(request.form["params"])]
      if "--sidecar" in cmd_args:
          return Response(
              "--sidecar not supported", 501, mimetype="text/plain"
          )
  
      ocrmypdf_args = ["ocrmypdf", *cmd_args, up_file, down_file]
      proc = run(
          ocrmypdf_args,
          capture_output=True,
          encoding="utf-8",
          check=False,
      )
      if proc.returncode != 0:
          stderr = proc.stderr
          return Response(stderr, 400, mimetype="text/plain")
  
      return send_from_directory(downloaddir.name, filename)
  
file_path: OCRmyPDF/misc/webservice.py
imports: from __future__ import annotations
  import os
  import shlex
  from subprocess import run
  from tempfile import TemporaryDirectory
  from flask import Flask, Response, request, send_from_directory
  from werkzeug.utils import secure_filename
label_desc: Use image node_id 2 for calling a global function with example usage: do_ocrmypdf(file) and returns: send_from_directory, Response, Response