rcajegas commited on
Commit
18b8552
·
1 Parent(s): 6c311bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -9
app.py CHANGED
@@ -1,11 +1,35 @@
1
- app = Flask(__name__)
 
2
 
3
- @app.route('/')
4
- def hospital_info():
5
- # Load the hospital data from the CSV file
6
- with open('data/hospital_data.csv', 'r') as f:
7
- reader = csv.DictReader(f)
8
- hospital_data = list(reader)
9
 
10
- # Render the hospital information template with the hospital data
11
- return render_template('hospital_info.html', hospital_data=hospital_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()