Nikhil0987 commited on
Commit
3c67127
·
verified ·
1 Parent(s): c3aaa36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -7,24 +7,18 @@ import google.generativeai as genai
7
 
8
 
9
 
10
- def add_to_json(new_data):
11
  with open("test.json", "r") as file:
12
- existing_data = json.load(file)
13
 
14
- # Assuming you want to add 'new_goal' and 'reminder' into existing_data
15
- existing_data.update(new_data)
 
 
 
16
 
17
  with open("test.json", "w") as file:
18
- json.dump(existing_data, file, indent=4)
19
-
20
- # Usage:
21
- new_data = {
22
-
23
-
24
- "goal": "enprom ",
25
-
26
-
27
- }
28
 
29
 
30
  GOOGLE_API_KEY="AIzaSyCUBaL7TdISL7lRuBy19_X0-OsZfgbIgEc"
 
7
 
8
 
9
 
10
+ def add_to_json(new_goal, new_reminder):
11
  with open("test.json", "r") as file:
12
+ data = json.load(file)
13
 
14
+ new_item = {
15
+ "goal": new_goal,
16
+ "reminder": new_reminder
17
+ }
18
+ data["goals"].append(new_item)
19
 
20
  with open("test.json", "w") as file:
21
+ json.dump(data, file, indent=4)
 
 
 
 
 
 
 
 
 
22
 
23
 
24
  GOOGLE_API_KEY="AIzaSyCUBaL7TdISL7lRuBy19_X0-OsZfgbIgEc"