Update app.py
Browse files
app.py
CHANGED
@@ -141,8 +141,14 @@ def app_function(uploaded_image: Optional[np.ndarray], country: Optional[str]) -
|
|
141 |
summary = "Found top 5 similar wildlife images."
|
142 |
|
143 |
logger.info("app_function: Performing taxonomic lookup for '%s'", proposed_scientific)
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
proposed_kingdom = taxonomic_data.get("kingdom", "N/A")
|
147 |
proposed_phylum = taxonomic_data.get("phylum", "N/A")
|
148 |
proposed_class = taxonomic_data.get("class", "N/A")
|
|
|
141 |
summary = "Found top 5 similar wildlife images."
|
142 |
|
143 |
logger.info("app_function: Performing taxonomic lookup for '%s'", proposed_scientific)
|
144 |
+
try:
|
145 |
+
response = requests.get(f"{SPECIES_RANK_API_URL}{proposed_scientific}", timeout=10)
|
146 |
+
response.raise_for_status()
|
147 |
+
taxonomic_data = response.json()
|
148 |
+
except requests.exceptions.RequestException as e:
|
149 |
+
logger.error("app_function: Taxonomic lookup failed for '%s'. Exception: %s", proposed_scientific, e)
|
150 |
+
taxonomic_data = {}
|
151 |
+
|
152 |
proposed_kingdom = taxonomic_data.get("kingdom", "N/A")
|
153 |
proposed_phylum = taxonomic_data.get("phylum", "N/A")
|
154 |
proposed_class = taxonomic_data.get("class", "N/A")
|