Accessing POST Data from WSGI

后端 未结 5 679
萌比男神i
萌比男神i 2020-12-08 00:45

I can\'t seem to figure out how to access POST data using WSGI. I tried the example on the wsgi.org website and it didn\'t work. I\'m using Python 3.0 right now. Please don\

5条回答
  •  再見小時候
    2020-12-08 01:22

    body= ''  # b'' for consistency on Python 3.0
    try:
        length= int(environ.get('CONTENT_LENGTH', '0'))
    except ValueError:
        length= 0
    if length!=0:
        body= environ['wsgi.input'].read(length)
    

    Note that WSGI is not yet fully-specified for Python 3.0, and much of the popular WSGI infrastructure has not been converted (or has been 2to3d, but not properly tested). (Even wsgiref.simple_server won't run.) You're in for a rough time doing WSGI on 3.0 today.

提交回复
热议问题