第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

如何使用 Bottle 在 python 中獲取由 nodeJS 服務(wù)器發(fā)送的請求數(shù)據(jù)

如何使用 Bottle 在 python 中獲取由 nodeJS 服務(wù)器發(fā)送的請求數(shù)據(jù)

MMTTMM 2022-08-16 18:59:17
如何在python中獲取和打印nodeJS發(fā)送的數(shù)據(jù)?我在這個節(jié)點(diǎn)Js模塊中使用ExpressJSapp.use("/py/sendomodel",  function (req, res, next) {     var oData = {        "Test":"FirstData"     }    var options = {        method: 'POST',        data : oData,        url: 'https://xxx.cfapps.us10.hana.ondemand.com/mprs/omodel',        headers: {            'cache-control': 'no-cache',            /*'Content-Type' :'application/json',*/            Connection: 'keep-alive',            'accept-encoding': 'gzip, deflate',            Host: 'xxxx.cfapps.us10.hana.ondemand.com',            'Cache-Control': 'no-cache',            Accept: '*/*',            'User-Agent': 'PostmanRuntime/7.15.0'        }    };    return request(options, function (error, response,body,data) {        if (error) throw new Error(error);    });});現(xiàn)在我被困在這里,如何打印發(fā)送的數(shù)據(jù)?這是python模塊from bottle import route, run, post, request, response@route('/mprs/omodel', method='POST')def profile():    #I tried all these without any success , I want to print the oData that I have sent via nodeJs    #request.body.read().decode('utf8')    temp = request.body.read()    #temp = request.json    #sol = request.forms    print(temp)       #jsonData = json.load(request.body)    #return jsonData    return(temp)
查看完整描述

1 回答

?
千巷貓影

TA貢獻(xiàn)1829條經(jīng)驗 獲得超7個贊

您有兩件獨(dú)立的事情要看,首先是查詢,其次是表單數(shù)據(jù)。為了以防萬一,我將兩者合并。在您的示例中,正文為空。由于沒有實際的HTML。


from bottle import route, run, post, request, response


def merge_dicts(*args):

    result = {}

    for dictionary in args:

        result.update(dictionary)

    return result


@post('/mprs/omodel')

def profile():

    payload = merge_dicts(dict(request.forms), dict(request.query.decode()))

    print(payload)

    print(payload['Test'])

    return payload


查看完整回答
反對 回復(fù) 2022-08-16
  • 1 回答
  • 0 關(guān)注
  • 176 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號