Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def do_POST(self):
- '''
- Handle POST requests.
- '''
- logging.debug('POST %s' % (self.path))
- # CITATION: http://stackoverflow.com/questions/4233218/python-basehttprequesthandler-post-variables
- ctype, pdict = cgi.parse_header(self.headers['content-type'])
- if ctype == 'multipart/form-data':
- postvars = cgi.parse_multipart(self.rfile, pdict)
- elif ctype == 'application/x-www-form-urlencoded':
- length = int(self.headers['content-length'])
- postvars = cgi.parse_qs(self.rfile.read(length), keep_blank_values=1)
- else:
- postvars = {}
- # Get the "Back" link.
- back = self.path if self.path.find('?') < 0 else self.path[:self.path.find('?')]
- # Print out logging information about the path and args.
- logging.debug('TYPE %s' % (ctype))
- logging.debug('PATH %s' % (self.path))
- logging.debug('ARGS %d' % (len(postvars)))
- if len(postvars):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement