Flask Post returning error
subhabrata.banerji at gmail.com
subhabrata.banerji at gmail.com
Mon May 18 11:05:38 EDT 2015
Dear Group,
I am trying to practice Flask and trying to correspond with it with through requests.
I am being able to DELETE, GET. But as I am doing POST it is not posting the data rather returning null.
I tried to search Flask and requests tutorials but did not get much.
I am newly practising Flask, and on Python2.7+ with Windows 7 Professional.
>>> var1=requests.get('http://127.0.0.1:5000/todos')
>>> var2=var2.text
>>> print var3
{
"todo1": {
"task": "build an API"
},
"todo2": {
"task": "How are you?"
},
"todo3": {
"task": "profit!"
}
}
>>> import json
>>> payload = {'key1': 'value1'}
>>> var4=requests.post('http://127.0.0.1:5000/todos', data=json.dumps(payload))
>>> var5=requests.get('http://127.0.0.1:5000/todos')
>>> var6=var5.text
>>> print var6
{
"todo1": {
"task": "build an API"
},
"todo3": {
"task": null
}
}
If anyone may kindly suggest what is the error I am doing.
Regards,
Subhabrata Banerjee.
More information about the Python-list
mailing list