badaoui HF Staff commited on
Commit
f04c85d
·
verified ·
1 Parent(s): 06e24a5

hide the login message when user is logged in

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -337,8 +337,9 @@ def get_title_image_html():
337
 
338
 
339
  with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Soft()) as demo:
340
- gr.Markdown("**You must be logged in to use this space**")
341
- gr.LoginButton(elem_id="login-button", elem_classes="center-button", min_width=250)
 
342
  title_image = get_title_image_html()
343
  gr.HTML(title_image)
344
  gr.HTML(TITLE)
@@ -583,5 +584,15 @@ with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Soft()) as demo:
583
  # Add spacing between tabs and content
584
  gr.Markdown("<br><br><br><br>")
585
 
 
 
 
 
 
 
 
 
 
 
586
  if __name__ == "__main__":
587
  demo.launch(debug=True)
 
337
 
338
 
339
  with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Soft()) as demo:
340
+ with gr.Group(visible=True) as login_group:
341
+ gr.Markdown("**You must be logged in to use this space**")
342
+ gr.LoginButton(elem_id="login-button", elem_classes="center-button", min_width=250)
343
  title_image = get_title_image_html()
344
  gr.HTML(title_image)
345
  gr.HTML(TITLE)
 
584
  # Add spacing between tabs and content
585
  gr.Markdown("<br><br><br><br>")
586
 
587
+ def check_login_status(request: gr.Request):
588
+ if request.username:
589
+ return gr.Group(visible=False)
590
+ return gr.Group(visible=True)
591
+
592
+ demo.load(
593
+ fn=check_login_status,
594
+ outputs=[login_group]
595
+ )
596
+
597
  if __name__ == "__main__":
598
  demo.launch(debug=True)