I've seen this question, but I want to be able to access the data that's POST'd, external from the handler.
Is there a way to do this?
Following is the code:
import BaseHTTPServer
HOST_NAME = ''
PORT_NUMBER=8088
postVars = ''
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_POST(s):
s.send_response(200)
s.end_headers()
varLen = int(s.headers['Content-Length'])
postVars = s.rfile.read(varLen)
print postVars
server_class = BaseHTTPServer.HTTPServer
httpd = server_class((HOST_NAME, PORT_NUMBER), MyHandler)
try:
httpd.handle_request()
except KeyboardInterrupt:
pass
print postVars
httpd.server_close()
postVars is valued during the Handler, but not after MyHandler