waloneai commited on
Commit
749cfed
·
verified ·
1 Parent(s): 00eb3fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -15
app.py CHANGED
@@ -280,18 +280,18 @@ def update(
280
  raise gr.Error(e)
281
 
282
 
283
- # Password protection logic
284
  def check_password(password):
285
  return password == PASSWORD
286
 
287
 
288
- # Gradio app with password protection
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.LoginButton(label="Login")
294
- logout_button = gr.LogoutButton(label="Logout")
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(is_logged_in):
409
- return gr.update(visible=is_logged_in)
 
 
 
410
 
411
  login_button.click(
412
- fn=check_password,
413
  inputs=password_input,
414
- outputs=None,
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