Spaces:
Running
Running
checkmark
Browse files
app.py
CHANGED
@@ -55,6 +55,7 @@ def hello(profile: gr.OAuthProfile | None, request: gr.Request) -> str:
|
|
55 |
|
56 |
with gr.Blocks() as demo:
|
57 |
gr.Markdown("# Gradio OAuth Space")
|
|
|
58 |
login_button = gr.LoginButton()
|
59 |
m1 = gr.Markdown()
|
60 |
demo.load(hello, inputs=None, outputs=m1)
|
@@ -68,10 +69,12 @@ with gr.Blocks() as demo:
|
|
68 |
def check_login_wrapper():
|
69 |
session = check_login_status()
|
70 |
if session is None:
|
71 |
-
|
|
|
72 |
else:
|
73 |
-
|
|
|
74 |
|
75 |
-
login_button.click(check_login_wrapper, inputs=None, outputs=m1)
|
76 |
|
77 |
demo.launch()
|
|
|
55 |
|
56 |
with gr.Blocks() as demo:
|
57 |
gr.Markdown("# Gradio OAuth Space")
|
58 |
+
checkmark = gr.HTML("<div id='checkmark' style='display: none;'>✅</div>")
|
59 |
login_button = gr.LoginButton()
|
60 |
m1 = gr.Markdown()
|
61 |
demo.load(hello, inputs=None, outputs=m1)
|
|
|
69 |
def check_login_wrapper():
|
70 |
session = check_login_status()
|
71 |
if session is None:
|
72 |
+
checkmark.update("<div id='checkmark' style='display: none;'>✅</div>")
|
73 |
+
return "❌ Not logged in."
|
74 |
else:
|
75 |
+
checkmark.update("<div id='checkmark' style='display: block;'>✅</div>")
|
76 |
+
return f"✅ Logged in as {session.get('username', 'Unknown')}"
|
77 |
|
78 |
+
login_button.click(check_login_wrapper, inputs=None, outputs=[m1, checkmark])
|
79 |
|
80 |
demo.launch()
|