亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

“Request”對象沒有屬性“get_json”Werkzeug

“Request”對象沒有屬性“get_json”Werkzeug

夢里花落0921 2023-09-26 16:15:55
我無法從我的請求中打印或讀取 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 安裝是最新的。


查看完整回答
反對 回復 2023-09-26
  • 1 回答
  • 0 關注
  • 115 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號