code: def upload_file():
      if request.method == "POST":
          if "file" not in request.files:
              return Response(
                  "No file in POST", 400, mimetype="text/plain"
              )
          file = request.files["file"]
          if file.filename == "":
              return Response(
                  "Empty filename", 400, mimetype="text/plain"
              )
          if not allowed_file(file.filename):
              return Response(
                  "Invalid filename", 400, mimetype="text/plain"
              )
          if file and allowed_file(file.filename):
              return do_ocrmypdf(file)
          return Response(
              "Some other problem", 400, mimetype="text/plain"
          )
  
      return """
      <!doctype html>
      <title>OCRmyPDF webservice</title>
      <h1>Upload a PDF (debug UI)</h1>
      <form method=post enctype=multipart/form-data>
        <label for="args">Command line parameters</label>
        <input type=textbox name=params>
        <label for="file">File to upload</label>
        <input type=file name=file>
        <input type=submit value=Upload>
      </form>
      <h4>Notice</h2>
      <div style="font-size: 70%; max-width: 34em;">
      <p>This is a webservice wrapper for OCRmyPDF.</p>
      <p>Copyright 2019 James R. Barlow</p>
      <p>This program is free software: you can redistribute it and/or modify
      it under the terms of the GNU Affero General Public License as published by
      the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.
      </p>
      <p>This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.
      </p>
      <p>
      You should have received a copy of the GNU Affero General Public License
      along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
      </p>
      </div>
      """
  
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 3 for calling a global function with example usage: upload_file() and returns: str, Response, Response, Response, Response, do_ocrmypdf