Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -35,14 +35,19 @@ class CalendarWrappedAPI:
|
|
35 |
'redirect_url': connection_request.redirectUrl
|
36 |
}
|
37 |
|
|
|
|
|
38 |
|
39 |
# Return redirect URL and wait time immediately
|
40 |
initial_response = {
|
41 |
'status': 'initiated',
|
42 |
-
'redirect_url':
|
43 |
'wait_time': wait_time,
|
44 |
'message': f'Please click the link below to authenticate. Waiting {wait_time} seconds for completion...'
|
45 |
-
}
|
|
|
|
|
|
|
46 |
# Check final status after waiting
|
47 |
final_status = 'active' # You would typically check the actual status here
|
48 |
self.connections[entity_id]['status'] = final_status
|
@@ -62,6 +67,8 @@ class CalendarWrappedAPI:
|
|
62 |
def check_connection_status(self, entity_id):
|
63 |
"""Check the connection status using entity_id"""
|
64 |
if entity_id in self.connections:
|
|
|
|
|
65 |
return {
|
66 |
'status': self.connections[entity_id]['status'],
|
67 |
'wait_time': wait_time,
|
@@ -144,12 +151,14 @@ def create_gradio_api():
|
|
144 |
connect_btn = gr.Button("Initialize Connection")
|
145 |
|
146 |
# New outputs for better visibility
|
|
|
147 |
redirect_link = gr.HTML(label="Authentication Link")
|
|
|
148 |
|
149 |
connect_btn.click(
|
150 |
fn=handle_connection,
|
151 |
inputs=[entity_id_input, redirect_url_input],
|
152 |
-
outputs=[redirect_link]
|
153 |
)
|
154 |
|
155 |
with gr.Tab("Status Check"):
|
|
|
35 |
'redirect_url': connection_request.redirectUrl
|
36 |
}
|
37 |
|
38 |
+
# Wait for random time between 60-100 seconds
|
39 |
+
wait_time = random.randint(60, 100)
|
40 |
|
41 |
# Return redirect URL and wait time immediately
|
42 |
initial_response = {
|
43 |
'status': 'initiated',
|
44 |
+
'redirect_url': connection_request.redirectUrl,
|
45 |
'wait_time': wait_time,
|
46 |
'message': f'Please click the link below to authenticate. Waiting {wait_time} seconds for completion...'
|
47 |
+
}
|
48 |
+
|
49 |
+
time.sleep(wait_time)
|
50 |
+
|
51 |
# Check final status after waiting
|
52 |
final_status = 'active' # You would typically check the actual status here
|
53 |
self.connections[entity_id]['status'] = final_status
|
|
|
67 |
def check_connection_status(self, entity_id):
|
68 |
"""Check the connection status using entity_id"""
|
69 |
if entity_id in self.connections:
|
70 |
+
wait_time = random.randint(60, 100)
|
71 |
+
time.sleep(wait_time)
|
72 |
return {
|
73 |
'status': self.connections[entity_id]['status'],
|
74 |
'wait_time': wait_time,
|
|
|
151 |
connect_btn = gr.Button("Initialize Connection")
|
152 |
|
153 |
# New outputs for better visibility
|
154 |
+
status_message = gr.Textbox(label="Status Message", interactive=False)
|
155 |
redirect_link = gr.HTML(label="Authentication Link")
|
156 |
+
connection_status = gr.Textbox(label="Connection Status", interactive=False)
|
157 |
|
158 |
connect_btn.click(
|
159 |
fn=handle_connection,
|
160 |
inputs=[entity_id_input, redirect_url_input],
|
161 |
+
outputs=[status_message, redirect_link, connection_status]
|
162 |
)
|
163 |
|
164 |
with gr.Tab("Status Check"):
|