Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -280,18 +280,18 @@ def update(
|
|
280 |
raise gr.Error(e)
|
281 |
|
282 |
|
283 |
-
#
|
284 |
def check_password(password):
|
285 |
return password == PASSWORD
|
286 |
|
287 |
|
288 |
-
# Gradio app with
|
289 |
with gr.Blocks() as demo:
|
290 |
# Login interface
|
291 |
with gr.Row():
|
292 |
password_input = gr.Textbox(label="Enter Password", type="password")
|
293 |
-
login_button = gr.
|
294 |
-
|
295 |
|
296 |
# Main app interface (hidden by default)
|
297 |
with gr.Row(visible=False) as main_interface:
|
@@ -405,20 +405,16 @@ with gr.Blocks() as demo:
|
|
405 |
)
|
406 |
|
407 |
# Show/hide main interface based on login status
|
408 |
-
def toggle_interface(
|
409 |
-
|
|
|
|
|
|
|
410 |
|
411 |
login_button.click(
|
412 |
-
fn=
|
413 |
inputs=password_input,
|
414 |
-
outputs=
|
415 |
-
success=toggle_interface,
|
416 |
-
queue=False,
|
417 |
-
)
|
418 |
-
logout_button.click(
|
419 |
-
fn=lambda: False,
|
420 |
-
outputs=main_interface,
|
421 |
-
queue=False,
|
422 |
)
|
423 |
|
424 |
# Launch the app with embedding enabled
|
|
|
280 |
raise gr.Error(e)
|
281 |
|
282 |
|
283 |
+
# Custom login system
|
284 |
def check_password(password):
|
285 |
return password == PASSWORD
|
286 |
|
287 |
|
288 |
+
# Gradio app with custom login system
|
289 |
with gr.Blocks() as demo:
|
290 |
# Login interface
|
291 |
with gr.Row():
|
292 |
password_input = gr.Textbox(label="Enter Password", type="password")
|
293 |
+
login_button = gr.Button("Login")
|
294 |
+
login_status = gr.Textbox(label="Login Status", interactive=False)
|
295 |
|
296 |
# Main app interface (hidden by default)
|
297 |
with gr.Row(visible=False) as main_interface:
|
|
|
405 |
)
|
406 |
|
407 |
# Show/hide main interface based on login status
|
408 |
+
def toggle_interface(password):
|
409 |
+
if check_password(password):
|
410 |
+
return gr.update(visible=True), "Login successful!"
|
411 |
+
else:
|
412 |
+
return gr.update(visible=False), "Invalid password. Please try again."
|
413 |
|
414 |
login_button.click(
|
415 |
+
fn=toggle_interface,
|
416 |
inputs=password_input,
|
417 |
+
outputs=[main_interface, login_status],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
418 |
)
|
419 |
|
420 |
# Launch the app with embedding enabled
|