import requests, time base = 'http://localhost:8080' headers = {'Authorization': 'Bearer invalid_token_12345'} print('Generating errors for 240 seconds...') for i in range(240): try: r = requests.get(f'{base}/api/v1/users/me', headers=headers, timeout=2) print(f'{i+1}/240: status={r.status_code}', end='\r') except Exception as e: print(f'{i+1}/240: error', end='\r') time.sleep(1) print('\nDone')