Keep gr.LoginButton and patch only its login-status label (fixes page not rendering)
Browse files
app.py
CHANGED
|
@@ -176,10 +176,13 @@ async def handle_certificate(name, profile: gr.OAuthProfile):
|
|
| 176 |
|
| 177 |
|
| 178 |
# gr.LoginButton shows logged-out visitors the server-side button value, which any API call to its click event can overwrite
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
| 183 |
|
| 184 |
# Gradio interface
|
| 185 |
with gr.Blocks() as demo:
|
|
@@ -197,7 +200,7 @@ with gr.Blocks() as demo:
|
|
| 197 |
gr.Markdown("---")
|
| 198 |
gr.Markdown("📝 **Note**: You must have completed [Unit 4](https://huggingface.co/learn/agents-course/unit4/introduction) and your Agent must have scored **above 30** to get your certificate.")
|
| 199 |
|
| 200 |
-
LoginButton()
|
| 201 |
with gr.Row():
|
| 202 |
name_input = gr.Text(label="Enter your name (this will appear on the certificate)")
|
| 203 |
generate_btn = gr.Button("Get my certificate")
|
|
|
|
| 176 |
|
| 177 |
|
| 178 |
# gr.LoginButton shows logged-out visitors the server-side button value, which any API call to its click event can overwrite
|
| 179 |
+
_original_check_login_status = gr.LoginButton._check_login_status
|
| 180 |
+
|
| 181 |
+
def _check_login_status(self, request: gr.Request):
|
| 182 |
+
self.value = "Sign in with Hugging Face"
|
| 183 |
+
return _original_check_login_status(self, request)
|
| 184 |
+
|
| 185 |
+
gr.LoginButton._check_login_status = _check_login_status
|
| 186 |
|
| 187 |
# Gradio interface
|
| 188 |
with gr.Blocks() as demo:
|
|
|
|
| 200 |
gr.Markdown("---")
|
| 201 |
gr.Markdown("📝 **Note**: You must have completed [Unit 4](https://huggingface.co/learn/agents-course/unit4/introduction) and your Agent must have scored **above 30** to get your certificate.")
|
| 202 |
|
| 203 |
+
gr.LoginButton()
|
| 204 |
with gr.Row():
|
| 205 |
name_input = gr.Text(label="Enter your name (this will appear on the certificate)")
|
| 206 |
generate_btn = gr.Button("Get my certificate")
|