python接口测试

import requests
from threading import Thread


def api():
    r = requests.post(url='http://127.0.0.1:8000/download_file_by_time_cpp', data=data)
    return r


if __name__ == '__main__':
    tasks = list()
    for i in range(10, 60):
        data = {
            'port': '80',
            'ip': '192.168.1.233',
            'USER': 'admin',
            'PASSWORD': 'placeint20',
            'start_time_string': '2021-11-26-152116',
            'end_time_string': '2021-11-26-152216',
            'channel': '0',
            'mode': '1'
        }
        data['start_time_string'] = data['start_time_string'][:-2]
        data['start_time_string'] = data['start_time_string'] + f'{i}'
        t = Thread(target=api)
        tasks.append(t)
        t.start()
    for t in tasks:
        t.join()
 

 

posted @ 2021-11-26 18:12  Abe1  阅读(9)  评论(0编辑  收藏  举报