1

Get parameters from BaseHTTPServer http GET request

 1 year ago
source link: https://fann.im/blog/2010/06/28/get-parameters-from-basehttpserver-http-get-request/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Get parameters from BaseHTTPServer http GET request

Jun 28, 2010

BaseHTTPHandler from the BaseHTTPServer module doesn’t seem to provide any convenient way to access http request parameters. What is the best way to parse the GET parameters from the path, and the POST parameters from the request body?

Right now, I’m using this for GET:

parsed_path = urlparse.urlparse(self.path)
try:
    params = dict([p.split('=') for p in parsed_path[4].split('&')])
except:
    params = {}

Was this page helpful?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK