How to parse the “request body” using python CGI?

前端 未结 2 941
醉梦人生
醉梦人生 2021-02-08 06:11

I just need to write a simple python CGI script to parse the contents of a POST request containing JSON. This is only test code so that I can test a client application until th

相关标签:
2条回答
  • 2021-02-08 06:54

    notice that if you call cgi.FieldStorage() before in your code, you can't get the body data from stdin, because it just be read once.

    0 讨论(0)
  • 2021-02-08 07:08

    If you're using CGI, just read data from stdin:

    import sys
    data = sys.stdin.read()
    
    0 讨论(0)
提交回复
热议问题