示例#1
0
    def put(self):
        data = request.form
        gw_id = data['gw_id']

        gateway = GatewayModel.find_by_id(gw_id)

        if gateway is None:
            gateway = GatewayModel(gw_id, data['gw_site'], data['gw_locate'])
        else:
            gateway.gw_site = data['gw_site']
            gateway.gw_locate = data['gw_locate']

        gateway.save_to_db()

        return gateway.json()
示例#2
0
    def put(self):
        data = request.form
        gw_id = data['gw_id']
        gateway = GatewayModel.find_by_id(gw_id)
        if gateway is None:
            gateway = GatewayModel(gw_id, **data)
        else:
            gateway.gw_id = data['gw_id']
            gateway.gw_model = data['gw_model']
            gateway.gw_sw = data['gw_sw']
            gateway.gw_lora_addr = data['gw_lora_addr']
            gateway.gw_site = data['gw_site']
            gateway.gw_locate = data['gw_locate']

        gateway.save_to_db()

        return gateway.json()