Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,35 @@
|
|
1 |
-
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
reader = csv.DictReader(f)
|
8 |
-
hospital_data = list(reader)
|
9 |
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import csv
|
2 |
+
import gradio as gr
|
3 |
|
4 |
+
# Load the hospital data from the CSV file
|
5 |
+
with open('hospital_data.csv', 'r') as f:
|
6 |
+
reader = csv.DictReader(f)
|
7 |
+
hospital_data = list(reader)
|
|
|
|
|
8 |
|
9 |
+
def display_hospital_info(index):
|
10 |
+
# Get the hospital data for the specified index
|
11 |
+
hospital = hospital_data[index]
|
12 |
+
|
13 |
+
# Format the hospital information as a string
|
14 |
+
info_str = f"{hospital['Hospital Name']}\n" \
|
15 |
+
f"{hospital['Address']}\n" \
|
16 |
+
f"{hospital['Number of Hospital Beds']} Beds\n" \
|
17 |
+
f"{hospital['Number of Employees']} Employees\n" \
|
18 |
+
f"{hospital['Services']}"
|
19 |
+
|
20 |
+
return info_str
|
21 |
+
|
22 |
+
# Define the Gradio interface
|
23 |
+
iface = gr.Interface(
|
24 |
+
fn=display_hospital_info,
|
25 |
+
inputs=gr.inputs.Slider(minimum=0, maximum=len(hospital_data)-1, step=1, default=0, label="Select a hospital:"),
|
26 |
+
outputs=gr.outputs.Textbox(label="Hospital Information"),
|
27 |
+
title="Hospital Information",
|
28 |
+
description="Display information on hospitals across the United States, including the number of hospital beds, employees, services offered, and address.",
|
29 |
+
theme="huggingface",
|
30 |
+
layout="vertical",
|
31 |
+
allow_flagging=False
|
32 |
+
)
|
33 |
+
|
34 |
+
# Launch the Gradio interface
|
35 |
+
iface.launch()
|