我有这个代码,它向我的服务器发送一个由web.py
运行的请求:
url = "https://sample.com/api"
auth_string = 'Basic ' + base64.encodestring('%s:%s' % ("usernamexxxx", "codexxxx"))[:-1]
headers = {"Content-Type": "application/json", "authorization": auth_string}
data = {"message":"WELCOME!..."}
req = urlfetch.fetch(url, method=urlfetch.POST, payload= simplejson.dumps(data), headers= headers)
response = req.content
因此,当我在网络服务器中收到此类请求时,我想检查请求的用户名和代码输入是否有效?我如何访问上面代码的给定数据?
答案 0 :(得分:0)
您可以通过os.environ
词典访问这些标题。