-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathposts.py
More file actions
65 lines (46 loc) · 1.1 KB
/
Copy pathposts.py
File metadata and controls
65 lines (46 loc) · 1.1 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
55
56
57
58
59
60
61
62
import requests
# HTTP Requests
# requests.get()
# requests.post()
# requests.put()
# requests.delete()
USERNAME = "zawawa"
TOKEN = "8jkjv8klo986g9905ds"
user_endpoint = "https://pixe.la/v1/users"
user_params = {
"token": TOKEN,
"username": USERNAME,
"agreeTermsOfService":"yes",
"notMinor":"yes",
}
# use a unique username
# response = requests.post(url=user_endpoint,json=user_params)
# print(response)
# print(response.text)
headers = {
"X-USER-TOKEN":TOKEN
}
# GRAPH
graph_endpoint = f"{user_endpoint}/{USERNAME}/graphs"
graph_params = {
"id":"graph6",
"name":"Boyfriend-Free",
"unit":"Days",
"type":"int",
"color":"ajisai",
}
pixel_data = {
"date": "20210908",
"quantity": "2.1"
}
# Adding dates
from datetime import datetime
today = datetime.now()
# print(today)
yesterday = datetime(2021, 9, 7)
print(yesterday.strftime("%Y-%m-%d"))
update_endpoint = f"{user_endpoint}/{USERNAME}/graphs/'graph6'/{yesterday}"
graph_response = requests.post(graph_endpoint,json=graph_params, headers=headers)
print(graph_response)
print(graph_response.text)
# PUT REQUESTS