-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlit_app.py
More file actions
71 lines (50 loc) · 1.61 KB
/
streamlit_app.py
File metadata and controls
71 lines (50 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""EVMS Streamlit entrypoint with official sidebar page navigation."""
import hmac
import os
from typing import Optional
from streamlit_bootstrap import ensure_project_on_path
import streamlit as st
ensure_project_on_path()
def _configured_password() -> Optional[str]:
try:
secret = st.secrets.get("APP_PASSWORD")
except Exception:
secret = None
if secret:
return str(secret)
env_value = os.getenv("EVMS_APP_PASSWORD")
if env_value:
return env_value
return None
def _password_gate() -> None:
expected_password = _configured_password()
if not expected_password:
return
if st.session_state.get("evms_authenticated", False):
return
st.title("EVMS")
st.caption("Protected access")
st.info("This application is password-protected.")
with st.form("evms_password_gate"):
password = st.text_input("Password", type="password")
submitted = st.form_submit_button("Open EVMS")
if submitted:
if hmac.compare_digest(password, expected_password):
st.session_state["evms_authenticated"] = True
st.rerun()
else:
st.error("Incorrect password.")
st.stop()
_password_gate()
st.set_page_config(
page_title="EVMS",
page_icon="🌍",
layout="wide",
)
pages = [
st.Page("pages/0_Inversion_Workspace.py", title="Inversion Workspace", icon="🌍", default=True),
st.Page("pages/1_How_EVMS_Works.py", title="How EVMS Works", icon="📘"),
st.Page("pages/2_Credits.py", title="Credits", icon="🧾"),
]
navigation = st.navigation(pages)
navigation.run()