Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,27 +11,38 @@ is_comfit_alive = False
|
|
| 11 |
clean_link = "comfit-copilot.mch250095.projects.jetstream-cloud.org:3000"
|
| 12 |
full_url = f"http://{clean_link}"
|
| 13 |
|
| 14 |
-
# Styled HTML for
|
| 15 |
-
|
| 16 |
-
<
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
</a>
|
| 36 |
</div>
|
| 37 |
"""
|
|
@@ -75,7 +86,7 @@ def get_current_status():
|
|
| 75 |
else:
|
| 76 |
is_comfit_alive = False
|
| 77 |
|
| 78 |
-
link_update = gr.update(value=
|
| 79 |
return status_text, f"π₯ Active Users: {active_user_count}", link_update
|
| 80 |
except Exception as e:
|
| 81 |
return f"β Error: {str(e)}", f"π₯ Active Users: {active_user_count}", gr.update()
|
|
@@ -112,7 +123,7 @@ def manage_instance():
|
|
| 112 |
try:
|
| 113 |
if requests.get(full_url, timeout=3).status_code < 500:
|
| 114 |
is_comfit_alive = True
|
| 115 |
-
yield ("π Success! ComFit is ready.", gr.update(value=
|
| 116 |
return
|
| 117 |
except: pass
|
| 118 |
yield (f"π Milestone 3/3: Software booting ({i+1}/24)...", gr.update(visible=False))
|
|
@@ -131,10 +142,7 @@ function playNotification(status) {
|
|
| 131 |
}
|
| 132 |
}
|
| 133 |
function resetTimer() { idleTime = 0; }
|
| 134 |
-
window.onmousemove = resetTimer;
|
| 135 |
-
window.onmousedown = resetTimer;
|
| 136 |
-
window.onclick = resetTimer;
|
| 137 |
-
window.onkeypress = resetTimer;
|
| 138 |
setInterval(function() {
|
| 139 |
idleTime++;
|
| 140 |
if (idleTime >= MAX_IDLE) {
|
|
@@ -161,7 +169,7 @@ with gr.Blocks() as demo:
|
|
| 161 |
|
| 162 |
status_label = gr.Label(value="Ready")
|
| 163 |
|
| 164 |
-
#
|
| 165 |
link_box = gr.HTML(visible=False)
|
| 166 |
|
| 167 |
gr.Markdown("---")
|
|
@@ -186,6 +194,14 @@ with gr.Blocks() as demo:
|
|
| 186 |
Once you sign-up using your email, a button will pop-up showing that you need to confirm email. You can safely ignore this step and continue with login using information you just used for sign-up.
|
| 187 |
""")
|
| 188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
live_status.change(None, inputs=live_status, js="(s) => playNotification(s)")
|
| 190 |
activate_btn.click(fn=manage_instance, outputs=[status_label, link_box])
|
| 191 |
refresh_btn.click(fn=get_current_status, outputs=[live_status, user_display, link_box])
|
|
|
|
| 11 |
clean_link = "comfit-copilot.mch250095.projects.jetstream-cloud.org:3000"
|
| 12 |
full_url = f"http://{clean_link}"
|
| 13 |
|
| 14 |
+
# Styled HTML for a flashing green block with black text
|
| 15 |
+
GREEN_FLASHING_LINK = f"""
|
| 16 |
+
<style>
|
| 17 |
+
@keyframes flash {{
|
| 18 |
+
0% {{ opacity: 1; }}
|
| 19 |
+
50% {{ opacity: 0.4; }}
|
| 20 |
+
100% {{ opacity: 1; }}
|
| 21 |
+
}}
|
| 22 |
+
.flashing-btn {{
|
| 23 |
+
display: inline-block;
|
| 24 |
+
padding: 20px 40px;
|
| 25 |
+
font-size: 26px;
|
| 26 |
+
font-weight: 900;
|
| 27 |
+
text-decoration: none;
|
| 28 |
+
color: black !important;
|
| 29 |
+
background-color: #39FF14;
|
| 30 |
+
border: 5px solid black;
|
| 31 |
+
border-radius: 4px;
|
| 32 |
+
text-align: center;
|
| 33 |
+
animation: flash 1s infinite;
|
| 34 |
+
box-shadow: 0 0 20px #39FF14;
|
| 35 |
+
transition: transform 0.2s;
|
| 36 |
+
}}
|
| 37 |
+
.flashing-btn:hover {{
|
| 38 |
+
animation: none;
|
| 39 |
+
transform: scale(1.05);
|
| 40 |
+
opacity: 1;
|
| 41 |
+
}}
|
| 42 |
+
</style>
|
| 43 |
+
<div style="text-align: center; margin: 30px 0;">
|
| 44 |
+
<a href="{full_url}" target="_blank" class="flashing-btn">
|
| 45 |
+
CLICK HERE FOR COMFIT COPILOT
|
| 46 |
</a>
|
| 47 |
</div>
|
| 48 |
"""
|
|
|
|
| 86 |
else:
|
| 87 |
is_comfit_alive = False
|
| 88 |
|
| 89 |
+
link_update = gr.update(value=GREEN_FLASHING_LINK if is_comfit_alive else "", visible=is_comfit_alive)
|
| 90 |
return status_text, f"π₯ Active Users: {active_user_count}", link_update
|
| 91 |
except Exception as e:
|
| 92 |
return f"β Error: {str(e)}", f"π₯ Active Users: {active_user_count}", gr.update()
|
|
|
|
| 123 |
try:
|
| 124 |
if requests.get(full_url, timeout=3).status_code < 500:
|
| 125 |
is_comfit_alive = True
|
| 126 |
+
yield ("π Success! ComFit is ready.", gr.update(value=GREEN_FLASHING_LINK, visible=True))
|
| 127 |
return
|
| 128 |
except: pass
|
| 129 |
yield (f"π Milestone 3/3: Software booting ({i+1}/24)...", gr.update(visible=False))
|
|
|
|
| 142 |
}
|
| 143 |
}
|
| 144 |
function resetTimer() { idleTime = 0; }
|
| 145 |
+
window.onmousemove = resetTimer; window.onmousedown = resetTimer; window.onclick = resetTimer; window.onkeypress = resetTimer;
|
|
|
|
|
|
|
|
|
|
| 146 |
setInterval(function() {
|
| 147 |
idleTime++;
|
| 148 |
if (idleTime >= MAX_IDLE) {
|
|
|
|
| 169 |
|
| 170 |
status_label = gr.Label(value="Ready")
|
| 171 |
|
| 172 |
+
# Flashing link box above instructions
|
| 173 |
link_box = gr.HTML(visible=False)
|
| 174 |
|
| 175 |
gr.Markdown("---")
|
|
|
|
| 194 |
Once you sign-up using your email, a button will pop-up showing that you need to confirm email. You can safely ignore this step and continue with login using information you just used for sign-up.
|
| 195 |
""")
|
| 196 |
|
| 197 |
+
# Logo Footer Section
|
| 198 |
+
gr.Markdown("---")
|
| 199 |
+
gr.Markdown("<center><h3>Supported By</h3></center>")
|
| 200 |
+
with gr.Row():
|
| 201 |
+
gr.Image("logo1.png", show_label=False, interactive=False, container=False, scale=1)
|
| 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 |
live_status.change(None, inputs=live_status, js="(s) => playNotification(s)")
|
| 206 |
activate_btn.click(fn=manage_instance, outputs=[status_label, link_box])
|
| 207 |
refresh_btn.click(fn=get_current_status, outputs=[live_status, user_display, link_box])
|