Upload 2 files
Browse files- app.py +30 -1
- auth_users.txt +3 -0
app.py
CHANGED
|
@@ -145,6 +145,35 @@ def continue_process(reformulated):
|
|
| 145 |
final_output, cost_message = generate_openai_response(reformulated)
|
| 146 |
return final_output, cost_message, gr.update(visible=True), gr.update(visible=True), gr.update(visible=False)
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
##############################################
|
| 149 |
# Gradio interface setup
|
| 150 |
with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Ubuntu"), "Arial", "sans-serif"],text_size='sm')) as ydcoza_face:
|
|
@@ -204,4 +233,4 @@ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Ubuntu"), "Arial
|
|
| 204 |
|
| 205 |
# Launch the Gradio interface
|
| 206 |
if __name__ == "__main__":
|
| 207 |
-
ydcoza_face.launch(auth=
|
|
|
|
| 145 |
final_output, cost_message = generate_openai_response(reformulated)
|
| 146 |
return final_output, cost_message, gr.update(visible=True), gr.update(visible=True), gr.update(visible=False)
|
| 147 |
|
| 148 |
+
##############################################
|
| 149 |
+
# Function to load users from a file
|
| 150 |
+
def load_auth_users(file_path):
|
| 151 |
+
auth_users = []
|
| 152 |
+
try:
|
| 153 |
+
with open(file_path, 'r') as file:
|
| 154 |
+
lines = file.readlines()
|
| 155 |
+
for line in lines:
|
| 156 |
+
# Strip any extra spaces or newline characters
|
| 157 |
+
line = line.strip()
|
| 158 |
+
if line: # Skip empty lines
|
| 159 |
+
username, password = line.split(',')
|
| 160 |
+
auth_users.append((username.strip(), password.strip()))
|
| 161 |
+
except FileNotFoundError:
|
| 162 |
+
print(f"Error: File not found - {file_path}")
|
| 163 |
+
except Exception as e:
|
| 164 |
+
print(f"An error occurred while loading auth users: {e}")
|
| 165 |
+
return auth_users
|
| 166 |
+
|
| 167 |
+
# Path to your auth users file
|
| 168 |
+
auth_users_file = "auth_users.txt"
|
| 169 |
+
|
| 170 |
+
# Load the auth users
|
| 171 |
+
auth_users = load_auth_users(auth_users_file)
|
| 172 |
+
|
| 173 |
+
if not auth_users:
|
| 174 |
+
raise ValueError("No valid users found. Please check your auth_users.txt file.")
|
| 175 |
+
# print(f"An error occurred while loading auth users: {e}")
|
| 176 |
+
|
| 177 |
##############################################
|
| 178 |
# Gradio interface setup
|
| 179 |
with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Ubuntu"), "Arial", "sans-serif"],text_size='sm')) as ydcoza_face:
|
|
|
|
| 233 |
|
| 234 |
# Launch the Gradio interface
|
| 235 |
if __name__ == "__main__":
|
| 236 |
+
ydcoza_face.launch(auth=auth_users, auth_message="Demo Login, Username: admin & Password: 1234")
|
auth_users.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
admin,1234
|
| 2 |
+
user1,password1
|
| 3 |
+
user2,password2
|