-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
54 lines (48 loc) · 1.27 KB
/
Copy pathmain.py
File metadata and controls
54 lines (48 loc) · 1.27 KB
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
from datetime import datetime
import os
import dotenv
dotenv.load_dotenv()
pixela_endpoint = "https://pixe.la/v1/users"
Token = os.getenv("TOKEN")
User= "shubhmrj"
user_params = {
"token": Token,
"username":User ,
"agreeTermsOfService": "yes",
"notMinor": "yes"
}
# response = requests.post(url=pixela_endpoint, json=user_params)
# print(response.text)
graph_endpoint = f"{pixela_endpoint}/{User}/graphs"
graph_config = {
"id": "graph1",
"name": "Cycling Graph",
"unit": "Km",
"type": "float",
"color": "ajisai"
}
headers = {
"X-USER-TOKEN": Token
}
# response=requests.post(url=graph_endpoint, json=graph_config , headers=headers)
# print(response.text)
today=datetime.now().strftime("%Y%m%d")
print(today)
date_config = {
"date": today,
"quantity": "7.5"
}
pixel_endpoint = f"{graph_endpoint}/graph1"
# response=requests.post(url=pixel_endpoint, json=date_config , headers=headers)
# print(response.text)
update_endpoint = f"{pixel_endpoint}/{today}"
upddate_config = {
"quantity": "85"
}
#
response=requests.put(url=update_endpoint, json=upddate_config , headers=headers)
print(response.text)
delete_endpoint = f"{pixel_endpoint}/{today}"
response=requests.delete(url=delete_endpoint , headers=headers)
print(response.text)