Accessing POST Data from WSGI

后端 未结 5 718
萌比男神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:25

    Even shorter

    l = int(env.get('CONTENT_LENGTH')) if env.get('CONTENT_LENGTH') else 0
    body = env['wsgi.input'].read(l) if l > 0 else ''
    

    This code works in production.

提交回复
热议问题