{
    "content": [
        {
            "type": "text",
            "text": "# cgi (pydoc)\n\n**Summary:** cgi - Support module for CGI (Common Gateway Interface) scripts.\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **MODULE REFERENCE** (8 lines)\n- **DESCRIPTION** (3 lines)\n- **CLASSES** (4 lines) — 2 subsections\n  - class FieldStorage (188 lines)\n  - class MiniFieldStorage (40 lines)\n- **FUNCTIONS** (1 lines) — 10 subsections\n  - parse (22 lines)\n  - parse_header (4 lines)\n  - parse_multipart (12 lines)\n  - print_arguments (1 lines)\n  - print_directory (2 lines)\n  - print_environ (2 lines)\n  - print_environ_usage (2 lines)\n  - print_exception (1 lines)\n  - print_form (2 lines)\n  - test (5 lines)\n- **DATA** (2 lines)\n- **VERSION** (2 lines)\n- **FILE** (3 lines)\n\n## Full Content\n\n### NAME\n\ncgi - Support module for CGI (Common Gateway Interface) scripts.\n\n### MODULE REFERENCE\n\nhttps://docs.python.org/3.10/library/cgi.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n\n### DESCRIPTION\n\nThis module defines a number of utilities for use by CGI scripts\nwritten in Python.\n\n### CLASSES\n\nbuiltins.object\nFieldStorage\nMiniFieldStorage\n\n#### class FieldStorage\n\n|  FieldStorage(fp=None, headers=None, outerboundary=b'', environ=environ({'PWD': '/home/chedong/chedong.com', 'SHLVL': '0', 'PATH': '/usr/local/bin:/usr/bin:/bin', '': '/usr/bin/pydoc3', 'LCCTYPE': 'C.UTF-8'}), keepblankvalues=0, strictparsing=0, limit=None, encoding='utf-8', errors='replace', maxnumfields=None, separator='&')\n|\n|  Store a sequence of fields, reading multipart/form-data.\n|\n|  This class provides naming, typing, files stored on disk, and\n|  more.  At the top level, it is accessible like a dictionary, whose\n|  keys are the field names.  (Note: None can occur as a field name.)\n|  The items are either a Python list (if there's multiple values) or\n|  another FieldStorage or MiniFieldStorage object.  If it's a single\n|  object, it has the following attributes:\n|\n|  name: the field name, if specified; otherwise None\n|\n|  filename: the filename, if specified; otherwise None; this is the\n|      client side filename, *not* the file name on which it is\n|      stored (that's a temporary file you don't deal with)\n|\n|  value: the value as a *string*; for file uploads, this\n|      transparently reads the file every time you request the value\n|      and returns *bytes*\n|\n|  file: the file(-like) object from which you can read the data *as\n|      bytes* ; None if the data is stored a simple string\n|\n|  type: the content-type, or None if not specified\n|\n|  typeoptions: dictionary of options specified on the content-type\n|      line\n|\n|  disposition: content-disposition, or None if not specified\n|\n|  dispositionoptions: dictionary of corresponding options\n|\n|  headers: a dictionary(-like) object (sometimes email.message.Message or a\n|      subclass thereof) containing *all* headers\n|\n|  The class is subclassable, mostly for the purpose of overriding\n|  the makefile() method, which is called internally to come up with\n|  a file open for reading and writing.  This makes it possible to\n|  override the default choice of storing all files in a temporary\n|  directory and unlinking them as soon as they have been opened.\n|\n|  Methods defined here:\n|\n|  bool(self)\n|\n|  contains(self, key)\n|      Dictionary style contains method.\n|\n|  del(self)\n|\n|  enter(self)\n|\n|  exit(self, *args)\n|\n|  getattr(self, name)\n|\n|  getitem(self, key)\n|      Dictionary style indexing.\n|\n|  init(self, fp=None, headers=None, outerboundary=b'', environ=environ({'PWD': '/home/chedong/chedong.com', 'SHLVL': '0', 'PATH': '/usr/local/bin:/usr/bin:/bin', '': '/usr/bin/pydoc3', 'LCCTYPE': 'C.UTF-8'}), keepblankvalues=0, strictparsing=0, limit=None, encoding='utf-8', errors='replace', maxnumfields=None, separator='&')\n|      Constructor.  Read multipart/* until last part.\n|\n|      Arguments, all optional:\n|\n|      fp              : file pointer; default: sys.stdin.buffer\n|          (not used when the request method is GET)\n|          Can be :\n|          1. a TextIOWrapper object\n|          2. an object whose read() and readline() methods return bytes\n|\n|      headers         : header dictionary-like object; default:\n|          taken from environ as per CGI spec\n|\n|      outerboundary   : terminating multipart boundary\n|          (for internal use only)\n|\n|      environ         : environment dictionary; default: os.environ\n|\n|      keepblankvalues: flag indicating whether blank values in\n|          percent-encoded forms should be treated as blank strings.\n|          A true value indicates that blanks should be retained as\n|          blank strings.  The default false value indicates that\n|          blank values are to be ignored and treated as if they were\n|          not included.\n|\n|      strictparsing: flag indicating what to do with parsing errors.\n|          If false (the default), errors are silently ignored.\n|          If true, errors raise a ValueError exception.\n|\n|      limit : used internally to read parts of multipart/form-data forms,\n|          to exit from the reading loop when reached. It is the difference\n|          between the form content-length and the number of bytes already\n|          read\n|\n|      encoding, errors : the encoding and error handler used to decode the\n|          binary stream to strings. Must be the same as the charset defined\n|          for the page sending the form (content-type : meta http-equiv or\n|          header)\n|\n|      maxnumfields: int. If set, then init throws a ValueError\n|          if there are more than n fields read by parseqsl().\n|\n|  iter(self)\n|\n|  len(self)\n|      Dictionary style len(x) support.\n|\n|  repr(self)\n|      Return a printable representation.\n|\n|  getfirst(self, key, default=None)\n|      Return the first value received.\n|\n|  getlist(self, key)\n|      Return list of received values.\n|\n|  getvalue(self, key, default=None)\n|      Dictionary style get() method, including 'value' lookup.\n|\n|  keys(self)\n|      Dictionary style keys() method.\n|\n|  makefile(self)\n|      Overridable: return a readable & writable file.\n|\n|      The file will be used as follows:\n|      - data is written to it\n|      - seek(0)\n|      - data is read from it\n|\n|      The file is opened in binary mode for files, in text mode\n|      for other fields\n|\n|      This version opens a temporary file for reading and writing,\n|      and immediately deletes (unlinks) it.  The trick (on Unix!) is\n|      that the file can still be used, but it can't be opened by\n|      another process, and it will automatically be deleted when it\n|      is closed or when the current process terminates.\n|\n|      If you want a more permanent file, you derive a class which\n|      overrides this method.  If you want a visible temporary file\n|      that is nevertheless automatically deleted when the script\n|      terminates, try defining a del method in a derived class\n|      which unlinks the temporary files you have created.\n|\n|  readbinary(self)\n|      Internal: read binary data.\n|\n|  readlines(self)\n|      Internal: read lines until EOF or outerboundary.\n|\n|  readlinestoeof(self)\n|      Internal: read lines until EOF.\n|\n|  readlinestoouterboundary(self)\n|      Internal: read lines until outerboundary.\n|      Data is read as bytes: boundaries and line ends must be converted\n|      to bytes for comparisons.\n|\n|  readmulti(self, environ, keepblankvalues, strictparsing)\n|      Internal: read a part that is itself multipart.\n|\n|  readsingle(self)\n|      Internal: read an atomic part.\n|\n|  readurlencoded(self)\n|      Internal: read data in query string format.\n|\n|  skiplines(self)\n|      Internal: skip lines until outer boundary if defined.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  FieldStorageClass = None\n|\n|  bufsize = 8192\n\n#### class MiniFieldStorage\n\n|  MiniFieldStorage(name, value)\n|\n|  Like FieldStorage, for use when no file uploads are possible.\n|\n|  Methods defined here:\n|\n|  init(self, name, value)\n|      Constructor from field name and value.\n|\n|  repr(self)\n|      Return printable representation.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  disposition = None\n|\n|  dispositionoptions = {}\n|\n|  file = None\n|\n|  filename = None\n|\n|  headers = {}\n|\n|  list = None\n|\n|  type = None\n|\n|  typeoptions = {}\n\n### FUNCTIONS\n\n#### parse\n\nParse a query in the environment or from a file (default stdin)\n\nArguments, all optional:\n\nfp              : file pointer; default: sys.stdin.buffer\n\nenviron         : environment dictionary; default: os.environ\n\nkeepblankvalues: flag indicating whether blank values in\npercent-encoded forms should be treated as blank strings.\nA true value indicates that blanks should be retained as\nblank strings.  The default false value indicates that\nblank values are to be ignored and treated as if they were\nnot included.\n\nstrictparsing: flag indicating what to do with parsing errors.\nIf false (the default), errors are silently ignored.\nIf true, errors raise a ValueError exception.\n\nseparator: str. The symbol to use for separating the query arguments.\nDefaults to &.\n\n#### parse_header\n\nParse a Content-type like header.\n\nReturn the main content-type and a dictionary of options.\n\n#### parse_multipart\n\nParse multipart input.\n\nArguments:\nfp   : input file\npdict: dictionary containing other parameters of content-type header\nencoding, errors: request encoding and error handler, passed to\nFieldStorage\n\nReturns a dictionary just like parseqs(): keys are the field names, each\nvalue is a list of values for that field. For non-file fields, the value\nis a list of strings.\n\n#### print_arguments\n\n#### print_directory\n\nDump the current directory as HTML.\n\n#### print_environ\n\nDump the shell environment as HTML.\n\n#### print_environ_usage\n\nDump a list of environment variables used by CGI as HTML.\n\n#### print_exception\n\n#### print_form\n\nDump the contents of a form as HTML.\n\n#### test\n\nRobust test CGI script, usable as main program.\n\nWrite minimal HTTP headers and dump all information provided to\nthe script in HTML form.\n\n### DATA\n\nall = ['MiniFieldStorage', 'FieldStorage', 'parse', 'parsemultipa...\n\n### VERSION\n\n2.6\n\n### FILE\n\n/usr/lib/python3.10/cgi.py\n\n"
        }
    ],
    "structuredContent": {
        "command": "cgi",
        "section": "",
        "mode": "pydoc",
        "summary": "cgi - Support module for CGI (Common Gateway Interface) scripts.",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "MODULE REFERENCE",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "CLASSES",
                "lines": 4,
                "subsections": [
                    {
                        "name": "class FieldStorage",
                        "lines": 188
                    },
                    {
                        "name": "class MiniFieldStorage",
                        "lines": 40
                    }
                ]
            },
            {
                "name": "FUNCTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "parse",
                        "lines": 22
                    },
                    {
                        "name": "parse_header",
                        "lines": 4
                    },
                    {
                        "name": "parse_multipart",
                        "lines": 12
                    },
                    {
                        "name": "print_arguments",
                        "lines": 1
                    },
                    {
                        "name": "print_directory",
                        "lines": 2
                    },
                    {
                        "name": "print_environ",
                        "lines": 2
                    },
                    {
                        "name": "print_environ_usage",
                        "lines": 2
                    },
                    {
                        "name": "print_exception",
                        "lines": 1
                    },
                    {
                        "name": "print_form",
                        "lines": 2
                    },
                    {
                        "name": "test",
                        "lines": 5
                    }
                ]
            },
            {
                "name": "DATA",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "FILE",
                "lines": 3,
                "subsections": []
            }
        ]
    }
}