-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_api.py
54 lines (37 loc) · 1.66 KB
/
test_api.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
import requests,json, os
from dotenv import load_dotenv
#load .env file
load_dotenv()
'''
To use api endpoints you must first register with a username and password to create an account and get your auth token,
then you may pass your token into the other endpoints for authentication.
'''
"""register and get token"""
# data = {'username': os.getenv('USERNAME'), 'password': os.getenv('PASSWORD')}
# r = requests.post('http://127.0.0.1:8000/api/auth/register',data=data)
# token = json.loads(r.content)['token']
# print(token)
"""login and get token"""
# data = {'username': os.getenv('USERNAME'), 'password': os.getenv('PASSWORD')}
# r = requests.post('http://127.0.0.1:8000/api/auth/login',data=data)
# token = json.loads(r.content)['token']
# print(token)
"""logout"""
# r = requests.get('http://127.0.0.1:8000/api/auth/logout', headers={"Authorization": f"Token {os.getenv('TOKEN')}"})
"""list users"""
# r = requests.get('http://127.0.0.1:8000/api/list_users', headers={"Authorization": f"Token {os.getenv('TOKEN')}"})
# res = json.loads(r.content)
# print(res)
"""update address"""
# data = {'address': os.getenv('ADDRESS')}
# r = requests.put('http://127.0.0.1:8000/api/user/update/address', data=data, headers={"Authorization": f"Token {os.getenv('TOKEN')}"})
# res = json.loads(r.content)
# print(res)
"""get nearby places"""
# r = requests.get('http://127.0.0.1:8000/api/getPlaces', headers={"Authorization": f"Token {os.getenv('TOKEN')}"})
# res = json.loads(r.content)
# print(res)
"""get group places"""
# r = requests.get('http://127.0.0.1:8000/api/group/get/places', headers={"Authorization": f"Token {os.getenv('TOKEN')}"})
# res = json.loads(r.content)
# print(res)