Skip to content

Instantly share code, notes, and snippets.

@Loupeznik
Created March 4, 2021 18:30
Show Gist options
  • Save Loupeznik/10558006bfa3a14237c88d349aee1202 to your computer and use it in GitHub Desktop.
Save Loupeznik/10558006bfa3a14237c88d349aee1202 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import requests
url = "http://127.0.0.1:8000/api/test"
payload={}
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer xxxxx' #add your API token
}
ok = 0
failed = 0
access_level = 1
for i in range(80):
response = requests.request("GET", url, headers=headers, data=payload)
if response.status_code == 200:
print ('Attempt ' + str(i + 1) + ': OK')
ok += 1
else:
print ('Attempt ' + str(i + 1) + ': FAILED (' + str(response.status_code) + ')')
failed += 1
#print(response.text)
print ('Tested for AccessLevel = ' + str(access_level) + ' user')
print ('OK: ' + str(ok))
print ('FAILED: ' + str(failed))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment