''' Author: your name Date: 2021-07-22 19:01:41 LastEditTime: 2021-07-22 21:46:18 LastEditors: Please set LastEditors Description: In User Settings Edit FilePath: \evm-store\tools\build_out\tests\http_interval.py ''' import json import random import requests from threading import Timer def send_request(): payload = { "system":{"free_size":1769792,"free_space_size":5156864,"used_space_size":1134592}, "lvgl":{"total_size":0,"free_cnt":0,"free_size":0,"free_biggest_size":0,"used_cnt":0,"used_pct":0,"frag_pct":0}, "evm":{"heap_total_size":2097152,"heap_used_size":575072,"heap_map_size":8192,"stack_total_size":102400,"stack_used_size":1312}, "image":[ {"uri":"evue_launcher","length":13515,"png_total_count":0,"png_uncompressed_size":0,"png_file_size":0}, {"uri":"kdgs_1_startup","length":3666,"png_total_count":0,"png_uncompressed_size":0,"png_file_size":0}, {"uri":"kdgs_1_index","length":5482,"png_total_count":0,"png_uncompressed_size":0,"png_file_size":0}, {"uri":"kdgs_1_story","length":5509,"png_total_count":0,"png_uncompressed_size":0,"png_file_size":0}, {"uri":"kdgs_1_storyList","length":9196,"png_total_count":0,"png_uncompressed_size":0,"png_file_size":0}, {"uri":"kdgs_1_storyPlay","length":25791,"png_total_count":6,"png_uncompressed_size":319376,"png_file_size":10770} ], "imei":"352099001761481","datetime":{"second":55,"minute":48,"hour":15,"day":21,"month":7,"year":2021,"weekday":3} } for item in payload.get("image"): item.update({ 'length': 0, 'png_total_count': 0, 'png_uncompressed_size': 0, 'png_file_size': 0 }) rand_index = random.randint(0, len(payload.get("image"))) if rand_index < len(payload.get("image")): print("------------------------------>") else: rand_index = rand_index - 1 print("rand_index ==>", rand_index) payload.get("image")[rand_index].update({ 'length': random.randint(0, 10000), 'png_total_count': random.randint(0, 10000), 'png_uncompressed_size': random.randint(100, 100000), 'png_file_size': random.randint(0, 10000) }) r = requests.post("http://localhost:3000/api/v1/evm_store/monitor", data=json.dumps(payload)) print(r.status_code) print(r.json()) t = Timer(3, send_request) t.run() if __name__ == "__main__": send_request()