我無法從我的請求中打印或讀取 json 數據。POST請求為application/json,發送的json有效。知道為什么“get_json”不存在嗎?from werkzeug.wrappers import Request, Responseimport [email protected] 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 安裝是最新的。
1 回答

函數式編程
TA貢獻1807條經驗 獲得超9個贊
我無法從我的請求中打印或讀取 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 安裝是最新的。
添加回答
舉報
0/150
提交
取消