在BaseHTTPHandler中处理html表单的正确方法

时间:2010-08-03 06:30:59

标签: python http forms basehttpserver

我知道我应该使用cgi.FieldStorage。但是我用什么来初始化呢?

def do_GET(self):
  form = cgi.FieldStorage(WHAT SHOULD BE HERE?!)

谢谢!

我做了搜索,但没有找到答案:(

1 个答案:

答案 0 :(得分:1)

通常什么都没有!

form = cgi.FieldStorage() 

来自消息来源

def __init__(self, fp=None, headers=None, outerboundary="",
             environ=os.environ, keep_blank_values=0, strict_parsing=0):
    """Constructor.  Read multipart/* until last part.

    Arguments, all optional:

    fp              : file pointer; default: sys.stdin
        (not used when the request method is GET)

    headers         : header dictionary-like object; default:
        taken from environ as per CGI spec

    outerboundary   : terminating multipart boundary
        (for internal use only)

    environ         : environment dictionary; default: os.environ

    keep_blank_values: flag indicating whether blank values in
        URL encoded forms should be treated as blank strings.
        A true value indicates that blanks should be retained as
        blank strings.  The default false value indicates that
        blank values are to be ignored and treated as if they were
        not included.

    strict_parsing: flag indicating what to do with parsing errors.
        If false (the default), errors are silently ignored.
        If true, errors raise a ValueError exception.

    """