| import gradio as gr |
| import csv |
| import os |
|
|
| APPT_FILE = "appointments.csv" |
|
|
| def load_appointments(): |
| if not os.path.exists(APPT_FILE): |
| return [["No appointments found"]] |
| with open(APPT_FILE, mode='r') as file: |
| reader = list(csv.reader(file)) |
| return reader[1:] if len(reader) > 1 else [["No appointments available"]] |
|
|
| def gradio_interface(): |
| with gr.Blocks() as demo: |
| gr.Markdown("## 📅 View Appointments") |
| output = gr.Dataframe(headers=["Appointment ID", "Patient Name", "Doctor", "Date", "Time"], datatype="str") |
| refresh = gr.Button("🔄 Refresh") |
| refresh.click(fn=load_appointments, outputs=output) |
| return demo |