Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ import plotly.express as px
|
|
| 11 |
import plotly.graph_objects as go
|
| 12 |
import os
|
| 13 |
import json
|
| 14 |
-
|
| 15 |
import urllib.parse # IMPORTANT: For joining URLs
|
| 16 |
|
| 17 |
# Configuration du logging
|
|
@@ -40,7 +40,7 @@ class PesticideDataFetcher:
|
|
| 40 |
HEADERS = {
|
| 41 |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
|
| 42 |
'Accept': 'application/json',
|
| 43 |
-
'Accept-Language': 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7',
|
| 44 |
"Content-Type": "application/json",
|
| 45 |
"Cache-Control": "no-cache"
|
| 46 |
}
|
|
@@ -128,7 +128,7 @@ class PesticideDataFetcher:
|
|
| 128 |
"""Preloads substance names from the API."""
|
| 129 |
logger.info("Preloading substances...")
|
| 130 |
url = f"{self.BASE_URL}/active_substances" # Correct endpoint
|
| 131 |
-
params = {"format": "json", "
|
| 132 |
substances_loaded = 0
|
| 133 |
|
| 134 |
data = self.fetch_data(url, params=params)
|
|
@@ -570,7 +570,7 @@ class PesticideApp:
|
|
| 570 |
substance_results.select( # Use .select() for interactive selection
|
| 571 |
fn=lambda evt: evt.data[0] if evt.data else None, # Extract ID
|
| 572 |
inputs=substance_results,
|
| 573 |
-
outputs=
|
| 574 |
)
|
| 575 |
|
| 576 |
|
|
|
|
| 11 |
import plotly.graph_objects as go
|
| 12 |
import os
|
| 13 |
import json
|
| 14 |
+
# Removed tqdm
|
| 15 |
import urllib.parse # IMPORTANT: For joining URLs
|
| 16 |
|
| 17 |
# Configuration du logging
|
|
|
|
| 40 |
HEADERS = {
|
| 41 |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
|
| 42 |
'Accept': 'application/json',
|
| 43 |
+
'Accept-Language': 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7', # Keeping this, but it might not be needed for /active_substances
|
| 44 |
"Content-Type": "application/json",
|
| 45 |
"Cache-Control": "no-cache"
|
| 46 |
}
|
|
|
|
| 128 |
"""Preloads substance names from the API."""
|
| 129 |
logger.info("Preloading substances...")
|
| 130 |
url = f"{self.BASE_URL}/active_substances" # Correct endpoint
|
| 131 |
+
params = {"format": "json", "api-version": "v2.0"} # Correct parameters, NO LANGUAGE
|
| 132 |
substances_loaded = 0
|
| 133 |
|
| 134 |
data = self.fetch_data(url, params=params)
|
|
|
|
| 570 |
substance_results.select( # Use .select() for interactive selection
|
| 571 |
fn=lambda evt: evt.data[0] if evt.data else None, # Extract ID
|
| 572 |
inputs=substance_results,
|
| 573 |
+
outputs=substance_select
|
| 574 |
)
|
| 575 |
|
| 576 |
|