File size: 1,200 Bytes
ab6b1dd
 
64a432f
e8d0f18
ab6b1dd
 
 
e8d0f18
 
ab6b1dd
e8d0f18
ab6b1dd
 
e8d0f18
64a432f
 
 
e8d0f18
 
 
 
64a432f
e8d0f18
 
64a432f
e8d0f18
06d7fc4
 
e8d0f18
06d7fc4
e8d0f18
 
06d7fc4
64a432f
e8d0f18
ab6b1dd
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import gradio as gr
from covid import Covid
import pandas as pd
import translate

# Fonction pour obtenir les données COVID-19 d'un pays
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

# Fonction pour afficher les données sous forme de dictionnaire
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

# Interface Gradio
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")

# Ajouter la fonction display_table à l'interface Gradio
iface.out = display_table

# Lancement de l'interface
iface.launch()