如何在python botlle服务器中发送application / x

编程入门 行业动态 更新时间:2024-10-12 16:26:56
如何在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-urlencoded

using 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

更多推荐

本文发布于:2023-08-05 00:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1423394.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:器中   如何在   botlle   python   application

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!