Skip to content Skip to sidebar Skip to footer

How To Parse The "request Body" Using Python Cgi?

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 the a

Solution 1:

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

importsysdata= sys.stdin.read()

Solution 2:

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.

Post a Comment for "How To Parse The "request Body" Using Python Cgi?"