shivanis14
commited on
Commit
•
f63431d
1
Parent(s):
f546480
Update rda.py
Browse files
rda.py
CHANGED
@@ -63,10 +63,16 @@ def find_nutrition(data):
|
|
63 |
return ""
|
64 |
try:
|
65 |
nutrition_per_serving = data['nutritionPerServing']
|
66 |
-
user_serving_size =
|
|
|
|
|
|
|
|
|
67 |
|
68 |
-
if not nutrition_per_serving
|
69 |
-
return json.dumps({"error": "Invalid nutrition data
|
|
|
|
|
70 |
|
71 |
# Process and respond with scaled values and daily percentages
|
72 |
scaled_nutrition, percentage_daily_values = process_nutrition_data(nutrition_per_serving, user_serving_size)
|
|
|
63 |
return ""
|
64 |
try:
|
65 |
nutrition_per_serving = data['nutritionPerServing']
|
66 |
+
user_serving_size = 0
|
67 |
+
|
68 |
+
if data['userServingSize'] != "":
|
69 |
+
user_serving_size = float(data['userServingSize'])
|
70 |
+
|
71 |
|
72 |
+
if not nutrition_per_serving:
|
73 |
+
return json.dumps({"error": "Invalid nutrition data"})
|
74 |
+
elif user_serving_size <= 0:
|
75 |
+
return json.dumps({"error": "Invalid user serving size"})
|
76 |
|
77 |
# Process and respond with scaled values and daily percentages
|
78 |
scaled_nutrition, percentage_daily_values = process_nutrition_data(nutrition_per_serving, user_serving_size)
|