LinkedinMonitor / app.py
GuglielmoTor's picture
Update app.py
734a45c verified
raw
history blame
1.08 kB
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)