Youssouf Traore
commited on
Commit
·
06d7fc4
1
Parent(s):
fb0b48d
Update app.py
Browse files
app.py
CHANGED
@@ -8,17 +8,6 @@ def get_covid_data(country):
|
|
8 |
data = covid.get_status_by_country_name(country)
|
9 |
return data
|
10 |
|
11 |
-
# Liste de tous les pays disponibles
|
12 |
-
covid = Covid()
|
13 |
-
countries = covid.list_countries()
|
14 |
-
|
15 |
-
# Interface Gradio avec un champ de texte
|
16 |
-
iface = gr.Interface(fn=get_covid_data,
|
17 |
-
inputs=gr.inputs.Textbox(label="Enter a country"),
|
18 |
-
outputs=gr.outputs.JSON(),
|
19 |
-
title="COVID-19 Data by Country",
|
20 |
-
description="Enter a country name to get COVID-19 data.")
|
21 |
-
|
22 |
# Fonction pour afficher les données sous forme de tableau
|
23 |
def display_table(data):
|
24 |
df = pd.DataFrame.from_dict(data, orient='index')
|
@@ -31,8 +20,17 @@ def display_table(data):
|
|
31 |
table_html = df.to_html()
|
32 |
return table_html
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
# Ajouter la fonction display_table à l'interface Gradio
|
35 |
-
iface.
|
|
|
36 |
|
37 |
# Lancement de l'interface
|
38 |
iface.launch()
|
|
|
8 |
data = covid.get_status_by_country_name(country)
|
9 |
return data
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
# Fonction pour afficher les données sous forme de tableau
|
12 |
def display_table(data):
|
13 |
df = pd.DataFrame.from_dict(data, orient='index')
|
|
|
20 |
table_html = df.to_html()
|
21 |
return table_html
|
22 |
|
23 |
+
# Interface Gradio avec une liste déroulante
|
24 |
+
iface = gr.Interface(fn=get_covid_data,
|
25 |
+
inputs="text",
|
26 |
+
outputs=gr.outputs.HTML(html_type="table"),
|
27 |
+
title="COVID-19 Data by Country",
|
28 |
+
description="Enter the name of a country to get COVID-19 data.",
|
29 |
+
example="France")
|
30 |
+
|
31 |
# Ajouter la fonction display_table à l'interface Gradio
|
32 |
+
iface.outs[0].type = "python"
|
33 |
+
iface.outs[0].update(display_table)
|
34 |
|
35 |
# Lancement de l'interface
|
36 |
iface.launch()
|