I have this code
httpd = HTTPServer(('127.0.0.1', 8000),SimpleHTTPRequestHandler)
httpd.handle_request()
httpd.handle_request() serves one request and then kills the server like intended. I want to capture this request as a variable so I can parse it later on. Something like
Request_Variable = httpd.handle_request()
*This code above doesn't work. But I'm looking for something similar Thanks
You could extend the
BaseHTTPRequestHandlerand implement your owndo_GET(resp.do_POST) method which is called when the server receives a GET (resp. POST) request.Check out the documentation to see what instance variables a
BaseHTTPRequestHandlerobject you can use. The variablespath,headers,rfileandwfilemay be of your interest.