Files
pragativeer-v2/test.py

13 lines
611 B
Python

import urllib.request, json
req = urllib.request.Request('http://localhost:8000/api/auth/login', data=b'{"email":"demo@pragativeer.com","password":"Pv9#kL2$mQ8!vX4@"}', headers={'Content-Type': 'application/json'})
res = urllib.request.urlopen(req)
data = json.loads(res.read().decode())
token = data['token']
req2 = urllib.request.Request('http://localhost:8000/api/admin/settings', headers={'Authorization': 'Bearer ' + token})
try:
res2 = urllib.request.urlopen(req2)
print("SETTINGS:", res2.read().decode())
except urllib.error.HTTPError as e:
print("ERR SETTINGS:", e.code, e.read().decode())