|
import gradio as gr |
|
from covid import Covid |
|
import pandas as pd |
|
import translate |
|
|
|
|
|
def get_covid_data(country): |
|
translator = translate.Translator(to_lang="fr") |
|
country_fr = translator.translate(country).lower() |
|
covid = Covid() |
|
data = covid.get_status_by_country_name(country_fr) |
|
return data |
|
|
|
|
|
def display_table(data): |
|
df = pd.DataFrame.from_dict(data, orient='index') |
|
df = df.rename(columns={ |
|
'confirmed': 'Cas Confirmés', |
|
'active': 'Cas Actifs', |
|
'deaths': 'Décès', |
|
'recovered': 'Guérisons' |
|
}) |
|
table_dict = df.to_dict(orient='index') |
|
return table_dict |
|
|
|
|
|
iface = gr.Interface(fn=get_covid_data, |
|
inputs="text", |
|
outputs="json", |
|
title="COVID-19 Data by Country", |
|
description="Entrez le nom d'un pays pour obtenir les données COVID-19.", |
|
example="France") |
|
|
|
|
|
|
|
|
|
|
|
iface.launch() |
|
|