【发布时间】:2021-01-15 19:36:07
【问题描述】:
我无法从我的请求中打印或读取 json 数据。 POST 请求是 application/json 并且发送的 json 是有效的。 知道为什么“get_json”不存在吗?
from werkzeug.wrappers import Request, Response
import json
@Request.application
def application(request):
data = request.get_json(force=True)
print(data)
return Response('Data Received')
if __name__ == '__main__':
from werkzeug.serving import run_simple
run_simple('localhost', 5000, application)
将request.get_json 替换为request.get_data 会以字符串形式返回json (d'{\n"example": "here"\n}')
我已确认我的 Werkzeug 安装是最新的。
【问题讨论】: