Flask 中 使用 request 库发请求

本文介绍了在Flask应用中如何使用request库进行HTTP请求,包括POST和GET方式。针对微信小程序退款,详细阐述了POST请求的流程,包括参数准备、签名获取、请求地址设置、headers构造及发送请求的过程。同时,也提及了GET请求的实现,参数通过params拼接在URL后面。
摘要由CSDN通过智能技术生成
  • Flask 中 使用 request 库发请求 
  • (get, post)    params = ,  body=  的区别

  • 使用 request 库发请求 

微信小程序退款请求request发送POST流程

1.微信开发者工具前端发送请求

 // js

wx.request({

    url: '*API地址',

    data:{

      openid:this.data.openid,

      totalPrice:totalPrice,

      priceAmount:,

      out_trade_no:out_trade_no,

    },

    success:(res)=>{

      console.log(res)

    },

    complete:(res)=>{

      console.log("cancel Quota complete")

    },

  })

2.API接收参数

 # app.py

   openid=request.args.get('openid')

      totalPrice=int(request.args.get('totalPrice'))

   priceAmount = int(request.args.get('priceAmount'))

       out_trade_no = request.args.get('out_tr
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值