yougandar commited on
Commit
d95e4a2
·
verified ·
1 Parent(s): 32750f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -35
app.py CHANGED
@@ -7,22 +7,6 @@ import os
7
  appointments_file_path = "appointments.csv"
8
  patients_file_path = "patients.csv"
9
 
10
- # Sample hospital user data for multi-tenant login (example)
11
- hospital_data = {
12
- "Hospital A": {
13
- "users": {
14
- "user1": "password1",
15
- "user2": "password2",
16
- },
17
- },
18
- "Hospital B": {
19
- "users": {
20
- "user3": "password3",
21
- "user4": "password4",
22
- },
23
- }
24
- }
25
-
26
  # Function to load CSV files
27
  def load_csv(file_path):
28
  """Load data from a CSV file, return an empty DataFrame if file is not found or empty."""
@@ -75,30 +59,17 @@ def get_appointment_details(patient_id):
75
  )
76
  return details
77
 
78
- # Authentication Function for Multi-Tenant Login
79
  def authenticate(hospital_name, username, password):
80
- """Authenticate the user based on hospital, username, and password."""
81
- print(f"Trying to authenticate for hospital: {hospital_name}, username: {username}, password: {password}")
82
-
83
- if hospital_name in hospital_data:
84
- if username in hospital_data[hospital_name]["users"]:
85
- if hospital_data[hospital_name]["users"][username] == password:
86
- print(f"Authentication successful for {hospital_name}, {username}")
87
- return True
88
- else:
89
- print(f"Incorrect password for {username} in {hospital_name}")
90
- else:
91
- print(f"Username {username} not found in {hospital_name}")
92
- else:
93
- print(f"Hospital {hospital_name} not found")
94
-
95
- return False
96
 
97
  # Gradio Interface
98
  def gradio_interface():
99
  with gr.Blocks() as demo:
100
  # Multi-Tenant Login Section
101
- hospital_name = gr.Dropdown(choices=list(hospital_data.keys()), label="Select Hospital")
102
  username = gr.Textbox(label="Username")
103
  password = gr.Textbox(label="Password", type="password")
104
  login_button = gr.Button("Login")
@@ -110,7 +81,7 @@ def gradio_interface():
110
  # Function to toggle authentication status
111
  def login_action(hospital_name, username, password):
112
  if authenticate(hospital_name, username, password):
113
- return gr.update(visible=True), "" # Show app section on successful login
114
  else:
115
  return gr.update(visible=False), "Invalid credentials or hospital name. Please try again."
116
 
 
7
  appointments_file_path = "appointments.csv"
8
  patients_file_path = "patients.csv"
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  # Function to load CSV files
11
  def load_csv(file_path):
12
  """Load data from a CSV file, return an empty DataFrame if file is not found or empty."""
 
59
  )
60
  return details
61
 
62
+ # Authentication Function for Multi-Tenant Login (accepts any username/password)
63
  def authenticate(hospital_name, username, password):
64
+ """Accept any credentials."""
65
+ print(f"Authentication bypassed for hospital: {hospital_name}, username: {username}, password: {password}")
66
+ return True # Always return True to accept any credentials
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
  # Gradio Interface
69
  def gradio_interface():
70
  with gr.Blocks() as demo:
71
  # Multi-Tenant Login Section
72
+ hospital_name = gr.Dropdown(choices=["Hospital A", "Hospital B"], label="Select Hospital")
73
  username = gr.Textbox(label="Username")
74
  password = gr.Textbox(label="Password", type="password")
75
  login_button = gr.Button("Login")
 
81
  # Function to toggle authentication status
82
  def login_action(hospital_name, username, password):
83
  if authenticate(hospital_name, username, password):
84
+ return gr.update(visible=True), "Login successful!" # Show app section on successful login
85
  else:
86
  return gr.update(visible=False), "Invalid credentials or hospital name. Please try again."
87