nakas commited on
Commit
3317091
·
verified ·
1 Parent(s): ec6491b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -72,13 +72,16 @@ def get_pollen_data(latitude, longitude):
72
  index_info = pollen.get('indexInfo', {})
73
  index_value = index_info.get('value', 'N/A')
74
  category = index_info.get('category', 'N/A')
75
- health_recs = pollen.get('healthRecommendations', {})
 
 
 
76
 
77
  formatted_pollen_info = f"- **{display_name}**: Index: {index_value} ({category})\n"
78
 
79
- # Append health recommendations if available
80
- if health_recs and health_recs.get('recommendations'):
81
- for rec in health_recs.get('recommendations').values():
82
  formatted_pollen_info += f" - {rec}\n"
83
 
84
  plant_type = pollen.get('plantType', 'UNKNOWN')
@@ -153,3 +156,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
153
 
154
  if __name__ == "__main__":
155
  demo.launch()
 
 
72
  index_info = pollen.get('indexInfo', {})
73
  index_value = index_info.get('value', 'N/A')
74
  category = index_info.get('category', 'N/A')
75
+
76
+ # *** FIX IS HERE ***
77
+ # The 'healthRecommendations' is a list of strings, not a dictionary.
78
+ health_recs = pollen.get('healthRecommendations', []) # Default to empty list
79
 
80
  formatted_pollen_info = f"- **{display_name}**: Index: {index_value} ({category})\n"
81
 
82
+ # Append health recommendations if available by iterating over the list.
83
+ if health_recs:
84
+ for rec in health_recs:
85
  formatted_pollen_info += f" - {rec}\n"
86
 
87
  plant_type = pollen.get('plantType', 'UNKNOWN')
 
156
 
157
  if __name__ == "__main__":
158
  demo.launch()
159
+