title: Extending BaseHTTPRequestHandler - getting the posted data
body: <p>I've seen <a href="https://stackoverflow.com/questions/4233218/python-basehttprequesthandler-post-variables">this</a> question, but I want to be able to access the data that's POST'd, external from the handler.</p>
  
  <p>Is there a way to do this?</p>
  
  <p>Following is the code:</p>
  
  <pre><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()
  </code></pre>
  
  <p>postVars is valued during the Handler, but not after MyHandler</p>