-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
75 lines (36 loc) · 1.52 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
refresh_endpoint='http://127.0.0.1:8000/api/token/refresh/'
login_endpoint='http://127.0.0.1:8000/api/token/'
blacklist_endpoint='http://127.0.0.1:8000/api/token/blacklist/'
signup_endpoint='http://127.0.0.1:8000/account/create-user/'
activate_endpoint='http://127.0.0.1:8000/auth/verify-email/'
product_endpoint='http://127.0.0.1:8000/products/all/'
import traceback
import requests
import datetime
# response=requests.post(blacklist_endpoint,{'refresh':'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTY1ODMyNjIxMCwiaWF0IjoxNjU4MjM5ODEwLCJqdGkiOiI1ZWEyMWY4YzczODU0MjEyYjcyZGZmODI3YzBhODQyMCIsInVzZXJfaWQiOjF9.SM9gL9aHmwn91WPQHYxxQPAIrqlkyFJHMQSI5438xms'})
response=requests.post(login_endpoint,{'email':'[email protected]','password':'heso123yam'})
print(response.json())
response=requests.get(product_endpoint)
print(response)
# response=requests.post(signup_endpoint,{'email':'[email protected]','password':'heso123yaml',
# 'fullname':'David Second',"password1":"heso123yaml"})
# response=requests.post(activate_endpoint,{'otp':'738fe5'})
# print(response)
'''
DATE TIME DEMO
current_time=datetime.datetime.now()
print(current_time)
timestamp=current_time.timestamp()
print(timestamp)
print(datetime.datetime.fromtimestamp(timestamp))
'''
def try_and_catch(func):
def inner(*args,**kwargs):
try:
func(*args,**kwargs)
except Exception as e:
traceback.print_exc()
return inner
@try_and_catch
def absurd_function():
return 1/0