web.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Monzo-Meter 作者: d-Rickyy-b 项目源码 文件源码
def catch():
    j = json.loads(request.data)
    data = j['data']
    if mode == VARIABLE_MAX:
        if data['is_load']:
            # If you put money onto your account, save the amount of money as peak
            r.set("peak", int(data['amount']))
            r.set("balance", int(getRedisValue("balance")) + int(data['amount']))
        else:
            # If money is withdrawn OR in case of refunds or chargebacks the peak won't be set
            r.set("balance", int(getRedisValue("balance")) + int(data['amount']))

            if int(data['amount']) > int(getRedisValue("peak")):
                # Only if the current balance is greater than the saved peak, save it as peak
                r.set("peak", int(data['amount']))
    else:
        r.set("balance", int(getRedisValue("balance")) + int(data['amount']))
        r.set("peak", max_bal)

    notify_particle()
    return "{} | {}".format(r.get("balance"), r.get("peak"))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号