diff --git a/main.py b/main.py index 2ae03fa..016d427 100644 --- a/main.py +++ b/main.py @@ -116,32 +116,32 @@ async def process_data(request: Request): r = await request.body() print(r) return 200 - try: - data = await request.body() - data = data.decode("utf-8") - data = json.loads(data) - payload = data["payload"] - receive_len = len(payload) - payload = json.loads(payload) - send_len = payload["l"] - if receive_len != send_len: - return 301 - m = payload["m"] - v = payload["v"] - t = payload["t"] - cid = v[0] - send_json = { - "devices": ["root.farm." + cid], - "timestamps": [int(time.time() * 1000)], - "measurements_list": [m], - "data_types_list": [dataTypes[t]], - "values_list": [v], - "is_aligned": False - } - r = requests.post(baseHost + insertUri, headers=headers, json=send_json) - return BaseResponse(data=r.json()) - except Exception as e: - return BaseResponse(code=500, msg=str(e)) + # try: + # data = await request.body() + # data = data.decode("utf-8") + # data = json.loads(data) + # payload = data["payload"] + # receive_len = len(payload) + # payload = json.loads(payload) + # send_len = payload["l"] + # if receive_len != send_len: + # return 301 + # m = payload["m"] + # v = payload["v"] + # t = payload["t"] + # cid = v[0] + # send_json = { + # "devices": ["root.farm." + cid], + # "timestamps": [int(time.time() * 1000)], + # "measurements_list": [m], + # "data_types_list": [dataTypes[t]], + # "values_list": [v], + # "is_aligned": False + # } + # r = requests.post(baseHost + insertUri, headers=headers, json=send_json) + # return BaseResponse(data=r.json()) + # except Exception as e: + # return BaseResponse(code=500, msg=str(e)) if __name__ == '__main__':