|
import requests |
|
import streamlit as st |
|
|
|
|
|
BASE_URL = "https://bziiitapi-api.azurewebsites.net" |
|
|
|
|
|
def get_labels(): |
|
url = f"{BASE_URL}/opendata/labels" |
|
response = requests.get(url) |
|
if response.status_code == 200: |
|
return response.json()["response"] |
|
else: |
|
st.error(f"Échec de récupération des labels: {response.text}") |
|
return [] |
|
|
|
|
|
def get_rse_projects(): |
|
url = f"{BASE_URL}/opendata/bordeaux-rse/projects" |
|
response = requests.get(url) |
|
if response.status_code == 200: |
|
return response.json()["response"] |
|
else: |
|
st.error(f"Échec de récupération des projets RSE: {response.text}") |
|
return [] |
|
|
|
|
|
def get_engaged_brands(): |
|
url = f"{BASE_URL}/opendata/bordeaux-rse/brands" |
|
response = requests.get(url) |
|
if response.status_code == 200: |
|
return response.json()["response"] |
|
else: |
|
st.error(f"Échec de récupération des marques engagées: {response.text}") |
|
return [] |
|
|
|
|
|
def get_bziiit_data(): |
|
labels = get_labels() |
|
rse_projects = get_rse_projects() |
|
engaged_brands = get_engaged_brands() |
|
|
|
bziiit_data = [] |
|
|
|
|
|
for label in labels: |
|
bziiit_data.append({ |
|
'type': 'label', |
|
'name': label.get('name', 'Unknown'), |
|
'description': label.get('description', 'Unknown'), |
|
'logo_url': label.get('logo_url', 'Unknown'), |
|
'labels': [label] |
|
}) |
|
|
|
for project in rse_projects: |
|
bziiit_data.append({ |
|
'type': 'project', |
|
'name': project.get('name', 'Unknown'), |
|
'labels': project.get('labels', []) |
|
}) |
|
|
|
for brand in engaged_brands: |
|
bziiit_data.append({ |
|
'type': 'brand', |
|
'name': brand.get('name', 'Unknown'), |
|
'logo_url': brand.get('logo_url', 'Unknown'), |
|
'description': brand.get('description', 'Unknown'), |
|
'labels': brand.get('labels', []) |
|
}) |
|
|
|
return bziiit_data |
|
|