File size: 1,077 Bytes
b560569
 
751e28f
b560569
 
751e28f
 
b560569
751e28f
b560569
751e28f
b560569
 
 
734a45c
 
 
 
b560569
751e28f
 
734a45c
751e28f
 
b560569
751e28f
 
734a45c
 
 
b560569
734a45c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr

# shared state
token_received = {"status": False}

# 1) this will be called by POST
def receive_token(accessToken: str):
    token_received["status"] = True
    return {"status": "ok"}

# 2) this just drives your UI
def check_status():
    return "✅ Code received" if token_received["status"] else "❌ Code not received"

def reset_status():
    token_received["status"] = False
    return "❌ Code not received"

with gr.Blocks() as demo:
    # we don’t actually show these widgets in the UI:
    hidden_token = gr.Textbox(visible=False)
    hidden_btn    = gr.Button(visible=False)
    # wire up the hidden POST→function
    hidden_btn.click(fn=receive_token, inputs=hidden_token, outputs=[])

    # your visible UI
    status_box = gr.Textbox(value=check_status(), label="Token Status", interactive=False)
    with gr.Row():
        refresh = gr.Button("Refresh").click(fn=check_status, outputs=status_box)
        reset = gr.Button("Reset Status").click(fn=reset_status, outputs=status_box)

demo.launch(server_name="0.0.0.0", server_port=7860)