Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -17,25 +17,31 @@ def check_status():
|
|
17 |
def show_token():
|
18 |
return token_received["token"] if token_received["status"] else ""
|
19 |
|
|
|
|
|
|
|
20 |
def reset_status():
|
21 |
token_received["status"] = False
|
22 |
token_received["token"] = ""
|
23 |
-
|
|
|
24 |
|
25 |
with gr.Blocks() as demo:
|
26 |
-
hidden_token = gr.Textbox(visible=False)
|
27 |
-
|
28 |
-
hidden_btn.
|
|
|
29 |
|
30 |
status_box = gr.Textbox(value=check_status(), label="Token Status", interactive=False)
|
31 |
token_display = gr.Textbox(value=show_token(), label="Received Token", interactive=False)
|
|
|
32 |
|
33 |
with gr.Row():
|
34 |
refresh = gr.Button("Refresh").click(fn=check_status, outputs=status_box)
|
35 |
-
reset = gr.Button("Reset Status").click(fn=reset_status, outputs=[status_box, token_display])
|
36 |
|
37 |
# ✅ Correct usage of Timer
|
38 |
timer = gr.Timer(1.0)
|
39 |
timer.tick(fn=show_token, outputs=token_display)
|
40 |
|
41 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
17 |
def show_token():
|
18 |
return token_received["token"] if token_received["status"] else ""
|
19 |
|
20 |
+
def show_client_id():
|
21 |
+
return token_received["client_id"] if token_received["status"] else ""
|
22 |
+
|
23 |
def reset_status():
|
24 |
token_received["status"] = False
|
25 |
token_received["token"] = ""
|
26 |
+
token_received["client_id"] = ""
|
27 |
+
return "❌ Code not received", "", ""
|
28 |
|
29 |
with gr.Blocks() as demo:
|
30 |
+
hidden_token = gr.Textbox(visible=False, elem_id="hidden_token")
|
31 |
+
hidden_client_id = gr.Textbox(visible=False, elem_id="hidden_client_id")
|
32 |
+
hidden_btn = gr.Button(visible=False, elem_id="hidden_btn")
|
33 |
+
hidden_btn.click(fn=receive_token, inputs=[hidden_token, hidden_client_id], outputs=[])
|
34 |
|
35 |
status_box = gr.Textbox(value=check_status(), label="Token Status", interactive=False)
|
36 |
token_display = gr.Textbox(value=show_token(), label="Received Token", interactive=False)
|
37 |
+
client_id_display = gr.Textbox(value=show_client_id(), label="Client ID", interactive=False)
|
38 |
|
39 |
with gr.Row():
|
40 |
refresh = gr.Button("Refresh").click(fn=check_status, outputs=status_box)
|
41 |
+
reset = gr.Button("Reset Status").click(fn=reset_status, outputs=[status_box, token_display, client_id_display])
|
42 |
|
43 |
# ✅ Correct usage of Timer
|
44 |
timer = gr.Timer(1.0)
|
45 |
timer.tick(fn=show_token, outputs=token_display)
|
46 |
|
47 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|