cgi.FieldStorage() not work for python requests.post but work for requests.get
程淼
crazytomcheng at gmail.com
Fri May 5 06:01:44 EDT 2017
here is the client use get
------------------------------------------------------------------
import json
import requests
url = "http://abc.com:11/ip"
auth = {"ip":["10.100.1.1","10.100.1.2"],
"time": "20170504133025"
}
try:
req = requests.get(url,params=auth)
except requests.exceptions.ConnectionError,e:
print e
else:
print req
print req.headers
print req.text
------------------------------------------------------------------
but not work for post
------------------------------------------------------------------
import json
import requests
url = "http://abc.com:11/ip"
auth = {"ip":["10.100.1.1","10.100.1.2"],
"time": "20170504133025"
}
try:
headers = {'Content-Type': 'application/json'}
req = requests.post(url=url,data=json.dumps(auth),headers=headers)
except requests.exceptions.ConnectionError,e:
print e
else:
print req
print req.headers
print req.text
------------------------------------------------------------------
arguments always get FieldStorage(None, None, [])
and i use other post way, it works.
------------------------------------------------------------------
<!DOCTYPE html>
<html><head><title>login</title></head>
<body>
<form action="http://abc.com:11/ip/" method="post">
<input type="text" name="ip"/>
<input type="text" name="time"/>
<input type="submit"/>
</form>
</body>
</html>
------------------------------------------------------------------
is this any problem requests.post(python) with cgi.FieldStorage ?
Thanks
More information about the Python-list
mailing list