如何在 python 瓶服务器中发送 application/x-www-form-urlencoded JSON 字符串
how to send application/x-www-form-urlencoded JSON string in python botlle server
我想post一个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",
这会起作用
但无法确定内容类型是否为 application/x-www-form-urlencoded
这是我发送数据的方式
import requests
d = {'spam': 20, 'eggs': 3}
requests.post("http://XX.XX.XX.XXX:8080", data=d)
使用request.forms.get('spam')
也在requests.post
url应该是http://XX.XX.XX.XXX:8080/ocr_response2
我想post一个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",
这会起作用
但无法确定内容类型是否为 application/x-www-form-urlencoded
这是我发送数据的方式
import requests
d = {'spam': 20, 'eggs': 3}
requests.post("http://XX.XX.XX.XXX:8080", data=d)
使用request.forms.get('spam')
也在requests.post
url应该是http://XX.XX.XX.XXX:8080/ocr_response2