Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,37 +47,55 @@ st.markdown(
|
|
| 47 |
""",
|
| 48 |
unsafe_allow_html=True
|
| 49 |
)
|
| 50 |
-
#
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
st.title("🔒 Protected")
|
| 66 |
-
st.write("This app requires a password to continue.")
|
| 67 |
-
|
| 68 |
-
with st.form("pw_form", clear_on_submit=False):
|
| 69 |
-
pw = st.text_input("Password", type="password")
|
| 70 |
-
ok = st.form_submit_button("Enter")
|
| 71 |
-
if ok:
|
| 72 |
-
if pw == expected:
|
| 73 |
-
st.session_state["_authed"] = True
|
| 74 |
-
st.rerun()
|
| 75 |
-
else:
|
| 76 |
-
st.error("Incorrect password. Please try again.")
|
| 77 |
-
st.stop() # block the rest of the script until authenticated
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
# =========================
|
| 83 |
# Helpers
|
|
@@ -404,7 +422,7 @@ if st.session_state.app_step == "intro":
|
|
| 404 |
st.markdown(
|
| 405 |
"This software is developed by *Smart Thinking AI-Solutions Team* to estimate UCS from drilling data."
|
| 406 |
)
|
| 407 |
-
st.subheader("
|
| 408 |
st.markdown(
|
| 409 |
"- Q, gpm — Flow rate (gallons per minute) \n"
|
| 410 |
"- SPP(psi) — Stand pipe pressure \n"
|
|
|
|
| 47 |
""",
|
| 48 |
unsafe_allow_html=True
|
| 49 |
)
|
| 50 |
+
# --- Password gate (branded) ---
|
| 51 |
+
def add_password_gate() -> bool:
|
| 52 |
+
"""
|
| 53 |
+
Shows a branded access screen until the correct password is entered.
|
| 54 |
+
Returns True when access is granted (or no password is configured).
|
| 55 |
+
"""
|
| 56 |
+
# Where the password is stored
|
| 57 |
+
try:
|
| 58 |
+
required = st.secrets.get("APP_PASSWORD", "")
|
| 59 |
+
except Exception:
|
| 60 |
+
required = os.environ.get("APP_PASSWORD", "")
|
| 61 |
+
|
| 62 |
+
# If no password configured, don't block access
|
| 63 |
+
if not required:
|
| 64 |
+
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
+
# Already authenticated?
|
| 67 |
+
if st.session_state.get("auth_ok", False):
|
| 68 |
+
return True
|
| 69 |
+
|
| 70 |
+
# --- Branded header -------------------------------------------------------
|
| 71 |
+
st.markdown(
|
| 72 |
+
f"""
|
| 73 |
+
<div style="display:flex;align-items:center;gap:14px;margin:8px 0 6px 0;">
|
| 74 |
+
<img src="{inline_logo()}" style="width:56px;height:56px;object-fit:contain"/>
|
| 75 |
+
<div>
|
| 76 |
+
<div style="font-size:1.9rem;font-weight:800;">ST_GeoMech_UCS</div>
|
| 77 |
+
<div style="color:#667085;">Smart Thinking • Secure Access</div>
|
| 78 |
+
</div>
|
| 79 |
+
</div>
|
| 80 |
+
<div style="font-size:1.25rem;font-weight:700;margin:8px 0 4px 0;">Protected Area</div>
|
| 81 |
+
<div style="color:#6b7280;margin-bottom:14px;">
|
| 82 |
+
Please enter your access key to continue.
|
| 83 |
+
</div>
|
| 84 |
+
""",
|
| 85 |
+
unsafe_allow_html=True
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
# Input + action
|
| 89 |
+
pwd = st.text_input("Access key", type="password", placeholder="••••••••")
|
| 90 |
+
col1, _ = st.columns([1, 3])
|
| 91 |
+
with col1:
|
| 92 |
+
if st.button("Unlock", type="primary", use_container_width=True):
|
| 93 |
+
if pwd == required:
|
| 94 |
+
st.session_state.auth_ok = True
|
| 95 |
+
st.rerun()
|
| 96 |
+
else:
|
| 97 |
+
st.error("Incorrect key. Please try again.")
|
| 98 |
+
st.stop()
|
| 99 |
|
| 100 |
# =========================
|
| 101 |
# Helpers
|
|
|
|
| 422 |
st.markdown(
|
| 423 |
"This software is developed by *Smart Thinking AI-Solutions Team* to estimate UCS from drilling data."
|
| 424 |
)
|
| 425 |
+
st.subheader("Expected Input Features (in Order)")
|
| 426 |
st.markdown(
|
| 427 |
"- Q, gpm — Flow rate (gallons per minute) \n"
|
| 428 |
"- SPP(psi) — Stand pipe pressure \n"
|