JatinkInnovision commited on
Commit
39b2e24
·
verified ·
1 Parent(s): 8199533

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -8,11 +8,9 @@ from openstack import exceptions
8
  # --- CONFIGURATION & SHARED STATE ---
9
  active_user_count = 0
10
  is_dekcib_alive = False
11
- # Target URL for De-KCIB
12
  clean_link = "149.165.152.222:3000"
13
  full_url = f"http://{clean_link}"
14
 
15
- # Styled HTML for the flashing Access Button
16
  GREEN_FLASHING_LINK = f"""
17
  <style>
18
  @keyframes flash {{
@@ -49,7 +47,6 @@ GREEN_FLASHING_LINK = f"""
49
  """
50
 
51
  def get_conn():
52
- """Authenticates with Jetstream2 using Application Credentials."""
53
  return openstack.connect(
54
  auth_url=os.getenv("OS_AUTH_URL"),
55
  application_credential_id=os.getenv("OS_APPLICATION_CREDENTIAL_ID"),
@@ -202,9 +199,14 @@ with gr.Blocks(title="De-KCIB Access Portal") as demo:
202
  gr.Image("logo2.png", show_label=False, interactive=False, container=False, scale=1)
203
  gr.Image("logo3.png", show_label=False, interactive=False, container=False, scale=1)
204
 
205
- # AUTO-REFRESH LOGIC: Every 5 seconds
 
206
  demo.load(fn=user_joined, outputs=user_display)
207
- demo.load(fn=get_current_status, outputs=[live_status, user_display, link_box], every=5)
 
 
 
 
208
 
209
  live_status.change(None, inputs=live_status, js="(s) => playNotification(s)")
210
  activate_btn.click(fn=manage_instance, outputs=[status_label, link_box])
 
8
  # --- CONFIGURATION & SHARED STATE ---
9
  active_user_count = 0
10
  is_dekcib_alive = False
 
11
  clean_link = "149.165.152.222:3000"
12
  full_url = f"http://{clean_link}"
13
 
 
14
  GREEN_FLASHING_LINK = f"""
15
  <style>
16
  @keyframes flash {{
 
47
  """
48
 
49
  def get_conn():
 
50
  return openstack.connect(
51
  auth_url=os.getenv("OS_AUTH_URL"),
52
  application_credential_id=os.getenv("OS_APPLICATION_CREDENTIAL_ID"),
 
199
  gr.Image("logo2.png", show_label=False, interactive=False, container=False, scale=1)
200
  gr.Image("logo3.png", show_label=False, interactive=False, container=False, scale=1)
201
 
202
+ # REPLACEMENT AUTO-REFRESH LOGIC
203
+ # Initialize the status on load
204
  demo.load(fn=user_joined, outputs=user_display)
205
+ demo.load(fn=get_current_status, outputs=[live_status, user_display, link_box])
206
+
207
+ # Setup a recurring timer for 5 seconds
208
+ status_timer = gr.Timer(5)
209
+ status_timer.tick(fn=get_current_status, outputs=[live_status, user_display, link_box])
210
 
211
  live_status.change(None, inputs=live_status, js="(s) => playNotification(s)")
212
  activate_btn.click(fn=manage_instance, outputs=[status_label, link_box])