Skip to content

Commit 6a80bfc

Browse files
committed
Day 38
- Workout Tracking Using Google Sheets - commented out some code of Day 37
1 parent 11ad79c commit 6a80bfc

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
- [Day 35](https://github.com/a092devs/100-days-of-python/tree/master/day035) - Keys, Authentication & Environment Variables: Send SMS
4444
- [Day 36](https://github.com/a092devs/100-days-of-python/tree/master/day036) - Stock Trading News Alert Project
4545
- [Day 37](https://github.com/a092devs/100-days-of-python/tree/master/day037) - Habit Tracking Project: API Post Requests & Headers
46+
- [Day 38](https://github.com/a092devs/100-days-of-python/tree/master/day038) - Workout Tracking Using Google Sheets
4647

4748
## ⚙ Tools and Technologies Covered
4849
- Python 3

day037/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565

6666
update_endpoint = f"{pixela_endpoint}/{PIXELA_UNAME}/graphs/{GRAPH_ID}/{today}"
6767

68-
new_pixel_data = {
69-
"quantity": "5"
70-
}
68+
# new_pixel_data = {
69+
# "quantity": input("How many hours did you code today? ")
70+
# }
7171

7272
# PUT - To Update any data
7373
# response = requests.put(url=update_endpoint, json=new_pixel_data, headers=headers)

day038/main.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import requests
2+
from os import environ
3+
from datetime import datetime
4+
from dotenv import load_dotenv
5+
6+
load_dotenv('config.env', override=True)
7+
8+
NUTRITIONIX_APP_ID = environ.get("NUTRITIONIX_APP_ID")
9+
NUTRITIONIX_APP_KEY = environ.get("NUTRITIONIX_APP_KEY")
10+
GENDER = "male"
11+
WEIGHT_KG = 48
12+
HEIGHT_CM = 167
13+
AGE = 26
14+
15+
SHEETY_ENDPOINT = environ.get(("SHEETY_ENDPOINT"))
16+
17+
nutrionix_endpoint = "https://trackapi.nutritionix.com/v2/natural/exercise"
18+
19+
exercise_query = input("Tell me which exercises you did? ")
20+
21+
headers = {
22+
"x-app-id": NUTRITIONIX_APP_ID,
23+
"x-app-key": NUTRITIONIX_APP_KEY
24+
}
25+
26+
nutrionix_params = {
27+
"query": exercise_query,
28+
"gender": GENDER,
29+
"weight_kg": WEIGHT_KG,
30+
"height_cm": HEIGHT_CM,
31+
"age": AGE
32+
}
33+
34+
response = requests.post(url=nutrionix_endpoint, json=nutrionix_params, headers=headers)
35+
result = response.json()
36+
# print(result)
37+
38+
current_date = datetime.now().strftime("%d/%m/%Y")
39+
current_time = datetime.now().strftime("%X")
40+
41+
for exercise in result["exercises"]:
42+
sheety_params = {
43+
"workout": {
44+
"date": current_date,
45+
"time": current_time,
46+
"exercise": exercise["name"].title(),
47+
"duration": exercise["duration_min"],
48+
"calories": exercise["nf_calories"]
49+
}
50+
}
51+
52+
sheet_resp = requests.post(url=SHEETY_ENDPOINT, json=sheety_params)
53+
# print(sheet_resp.text)

0 commit comments

Comments
 (0)