Commit
·
c5b60b4
1
Parent(s):
d63f1d2
Pytorch v.41
Browse files
__pycache__/localisation.cpython-312.pyc
CHANGED
|
Binary files a/__pycache__/localisation.cpython-312.pyc and b/__pycache__/localisation.cpython-312.pyc differ
|
|
|
__pycache__/organisations_engagees.cpython-312.pyc
CHANGED
|
Binary files a/__pycache__/organisations_engagees.cpython-312.pyc and b/__pycache__/organisations_engagees.cpython-312.pyc differ
|
|
|
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from organisations_engagees import display_organisations_engagees
|
| 3 |
from localisation import display_map
|
|
@@ -6,18 +7,24 @@ def get_data():
|
|
| 6 |
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
|
| 7 |
try:
|
| 8 |
response = requests.get(url)
|
| 9 |
-
response.
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
else:
|
| 15 |
-
st.error("
|
| 16 |
return []
|
| 17 |
except requests.RequestException as e:
|
| 18 |
-
st.error(f"
|
| 19 |
return []
|
| 20 |
-
|
| 21 |
def main():
|
| 22 |
st.sidebar.title("Navigation")
|
| 23 |
app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Localisation des Entreprises"])
|
|
|
|
| 1 |
+
import requests # Ajoutez cette ligne au début de votre fichier
|
| 2 |
import streamlit as st
|
| 3 |
from organisations_engagees import display_organisations_engagees
|
| 4 |
from localisation import display_map
|
|
|
|
| 7 |
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
|
| 8 |
try:
|
| 9 |
response = requests.get(url)
|
| 10 |
+
if response.status_code == 200:
|
| 11 |
+
data = response.json()
|
| 12 |
+
records = data.get("records", [])
|
| 13 |
+
cleaned_data = []
|
| 14 |
+
for record in records:
|
| 15 |
+
fields = record.get("fields", {})
|
| 16 |
+
geoloc = fields.get("geolocalisation")
|
| 17 |
+
if geoloc and isinstance(geoloc, list) and len(geoloc) == 2:
|
| 18 |
+
lat, lon = geoloc
|
| 19 |
+
cleaned_data.append({"lat": lat, "lon": lon, "name": fields.get("nom_courant_denomination", "Inconnu")})
|
| 20 |
+
return cleaned_data
|
| 21 |
else:
|
| 22 |
+
st.error(f"Failed to fetch data. Status code: {response.status_code}")
|
| 23 |
return []
|
| 24 |
except requests.RequestException as e:
|
| 25 |
+
st.error(f"Error occurred: {e}")
|
| 26 |
return []
|
| 27 |
+
|
| 28 |
def main():
|
| 29 |
st.sidebar.title("Navigation")
|
| 30 |
app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Localisation des Entreprises"])
|
organisations_engagees.py
CHANGED
|
@@ -2,22 +2,6 @@ import streamlit as st
|
|
| 2 |
import pandas as pd
|
| 3 |
import requests
|
| 4 |
|
| 5 |
-
def get_data():
|
| 6 |
-
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
|
| 7 |
-
try:
|
| 8 |
-
response = requests.get(url)
|
| 9 |
-
response.raise_for_status() # Cela va déclencher une exception pour les réponses non-200
|
| 10 |
-
data = response.json()
|
| 11 |
-
records = data.get("records", [])
|
| 12 |
-
if records:
|
| 13 |
-
return [record.get("fields") for record in records]
|
| 14 |
-
else:
|
| 15 |
-
st.error("Aucun enregistrement trouvé dans les données de l'API.")
|
| 16 |
-
return []
|
| 17 |
-
except requests.RequestException as e:
|
| 18 |
-
st.error(f"Erreur lors de la récupération des données de l'API: {e}")
|
| 19 |
-
return []
|
| 20 |
-
|
| 21 |
def display_organisations_engagees(data):
|
| 22 |
st.markdown("## OPEN DATA RSE")
|
| 23 |
st.markdown("### Découvrez les organisations engagées RSE de la métropole de Bordeaux")
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import requests
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
def display_organisations_engagees(data):
|
| 6 |
st.markdown("## OPEN DATA RSE")
|
| 7 |
st.markdown("### Découvrez les organisations engagées RSE de la métropole de Bordeaux")
|