如何在python botlle服务器中发送application / x-www-form-urlencoded JSON字符串(how to send application/x-www-form-urlencoded JSON string in python botlle server)
我想以格式发布JSON字符串
application/x-www-form-urlencoded使用python的瓶子
这是我写的网络服务
import json from bottle import route, run, request @route('/ocr_response2', method='POST') def ocr_response2(): word = request.json print word if __name__ == "__main__": run(host='0.0.0.0', port=8080, debug=True)我知道如果contentType: "application/json",这将有效contentType: "application/json",但无法弄清楚内容类型是否为application/x-www-form-urlencoded
这是我发送数据的方式
import requests d = {'spam': 20, 'eggs': 3} requests.post("http://XX.XX.XX.XXX:8080", data=d)I want to post a JSON string in the format of
application/x-www-form-urlencodedusing python's bottle
Here's the web service I had written
import json from bottle import route, run, request @route('/ocr_response2', method='POST') def ocr_response2(): word = request.json print word if __name__ == "__main__": run(host='0.0.0.0', port=8080, debug=True)I know this would work if contentType: "application/json", But can't figure out if content type is application/x-www-form-urlencoded
Here's how i am sending the data
import requests d = {'spam': 20, 'eggs': 3} requests.post("http://XX.XX.XX.XXX:8080", data=d)最满意答案
使用request.forms.get('spam')
http://XX.XX.XX.XXX:8080/ocr_response2网址也应该是http://XX.XX.XX.XXX:8080/ocr_response2
use request.forms.get('spam')
also in requests.post url should be http://XX.XX.XX.XXX:8080/ocr_response2
更多推荐
发布评论