Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,6 @@ st.set_page_config(page_title="SAAS Template App", page_icon="🧊", layout="wid
|
|
| 12 |
with open("config.yaml") as file:
|
| 13 |
config = yaml.load(file, Loader=SafeLoader)
|
| 14 |
|
| 15 |
-
|
| 16 |
authenticator = stauth.Authenticate(
|
| 17 |
config["credentials"],
|
| 18 |
config["cookie"]["name"],
|
|
@@ -32,20 +31,27 @@ with st.sidebar:
|
|
| 32 |
if not st.session_state["authentication_status"]:
|
| 33 |
st.markdown(
|
| 34 |
"""
|
| 35 |
-
# Welcome to **
|
| 36 |
|
| 37 |
-
Introduction
|
| 38 |
|
| 39 |
### 🖱️Press "R" on your keyboard⌨️ to rerun the app for faster loading 🔄.
|
| 40 |
|
|
|
|
|
|
|
| 41 |
"""
|
| 42 |
)
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
with st.expander("Login 🔒", expanded=True):
|
| 45 |
authenticator.login("Login", "main")
|
| 46 |
|
| 47 |
if st.session_state["authentication_status"]:
|
| 48 |
-
authenticator.logout("Logout", "main", key="
|
| 49 |
st.write(f'Welcome *{st.session_state["name"]}*')
|
| 50 |
st.title(
|
| 51 |
"You logged in! You can choose a session in the bottom of the sidebar and view content."
|
|
@@ -90,7 +96,7 @@ with st.sidebar:
|
|
| 90 |
except Exception as e:
|
| 91 |
st.error(e)
|
| 92 |
|
| 93 |
-
with st.expander("Register user 😋"
|
| 94 |
try:
|
| 95 |
# payment_key = st.text_input("Enter Payment Key:")
|
| 96 |
if authenticator.register_user("Register user", preauthorization=False):
|
|
@@ -119,15 +125,15 @@ with st.sidebar:
|
|
| 119 |
unsafe_allow_html=True,
|
| 120 |
)
|
| 121 |
|
| 122 |
-
# Dump data
|
| 123 |
-
with open("config.yaml", "w") as file:
|
| 124 |
-
yaml.dump(config, file, default_flow_style=False)
|
| 125 |
-
|
| 126 |
-
|
| 127 |
# Main
|
| 128 |
if st.session_state["authentication_status"]:
|
|
|
|
| 129 |
st.markdown(
|
| 130 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
"""
|
| 132 |
)
|
| 133 |
|
|
@@ -135,13 +141,19 @@ if st.session_state["authentication_status"]:
|
|
| 135 |
# TODO
|
| 136 |
main_chatbot_page()
|
| 137 |
|
| 138 |
-
# Log out
|
| 139 |
with st.sidebar:
|
| 140 |
with st.expander("Login 🔒", expanded=True):
|
| 141 |
authenticator.login("Login", "main")
|
| 142 |
|
| 143 |
if st.session_state["authentication_status"]:
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
st.write(f'Welcome *{st.session_state["name"]}*')
|
| 146 |
st.title(
|
| 147 |
"You logged in! You can choose a session in the bottom of the sidebar and view content."
|
|
@@ -154,14 +166,3 @@ if st.session_state["authentication_status"]:
|
|
| 154 |
st.error("Username/password is incorrect")
|
| 155 |
elif st.session_state["authentication_status"] is None:
|
| 156 |
st.warning("Please enter your username and password")
|
| 157 |
-
|
| 158 |
-
# Credit:
|
| 159 |
-
current_year = current_year() # This will print the current year
|
| 160 |
-
st.markdown(
|
| 161 |
-
f"""
|
| 162 |
-
<h6 style='text-align: left;'>Copyright © 2010-{current_year} Present Yiqiao Yin</h6>
|
| 163 |
-
""",
|
| 164 |
-
unsafe_allow_html=True,
|
| 165 |
-
)
|
| 166 |
-
else:
|
| 167 |
-
st.warning("Please login to view content.")
|
|
|
|
| 12 |
with open("config.yaml") as file:
|
| 13 |
config = yaml.load(file, Loader=SafeLoader)
|
| 14 |
|
|
|
|
| 15 |
authenticator = stauth.Authenticate(
|
| 16 |
config["credentials"],
|
| 17 |
config["cookie"]["name"],
|
|
|
|
| 31 |
if not st.session_state["authentication_status"]:
|
| 32 |
st.markdown(
|
| 33 |
"""
|
| 34 |
+
# Welcome to **Name of App** 🎶🤖
|
| 35 |
|
| 36 |
+
Introduction / Instruction Manual ...🚀
|
| 37 |
|
| 38 |
### 🖱️Press "R" on your keyboard⌨️ to rerun the app for faster loading 🔄.
|
| 39 |
|
| 40 |
+
### 🔒Sample login info - User: "jsmith" | Password: "abc"
|
| 41 |
+
|
| 42 |
"""
|
| 43 |
)
|
| 44 |
|
| 45 |
+
# Default video
|
| 46 |
+
st.write(
|
| 47 |
+
"👋 Guide to Data Science, Machine Learning, and Artificial Intelligence!"
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
with st.expander("Login 🔒", expanded=True):
|
| 51 |
authenticator.login("Login", "main")
|
| 52 |
|
| 53 |
if st.session_state["authentication_status"]:
|
| 54 |
+
authenticator.logout("Logout", "main", key="unique_key_login")
|
| 55 |
st.write(f'Welcome *{st.session_state["name"]}*')
|
| 56 |
st.title(
|
| 57 |
"You logged in! You can choose a session in the bottom of the sidebar and view content."
|
|
|
|
| 96 |
except Exception as e:
|
| 97 |
st.error(e)
|
| 98 |
|
| 99 |
+
with st.expander("Register user 😋"):
|
| 100 |
try:
|
| 101 |
# payment_key = st.text_input("Enter Payment Key:")
|
| 102 |
if authenticator.register_user("Register user", preauthorization=False):
|
|
|
|
| 125 |
unsafe_allow_html=True,
|
| 126 |
)
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
# Main
|
| 129 |
if st.session_state["authentication_status"]:
|
| 130 |
+
|
| 131 |
st.markdown(
|
| 132 |
"""
|
| 133 |
+
# Homepage 🎶🤖
|
| 134 |
+
|
| 135 |
+
Content goes here.
|
| 136 |
+
|
| 137 |
"""
|
| 138 |
)
|
| 139 |
|
|
|
|
| 141 |
# TODO
|
| 142 |
main_chatbot_page()
|
| 143 |
|
|
|
|
| 144 |
with st.sidebar:
|
| 145 |
with st.expander("Login 🔒", expanded=True):
|
| 146 |
authenticator.login("Login", "main")
|
| 147 |
|
| 148 |
if st.session_state["authentication_status"]:
|
| 149 |
+
try:
|
| 150 |
+
authenticator.logout("Logout", "main", key="unique_key")
|
| 151 |
+
except KeyError:
|
| 152 |
+
pass # ignore it
|
| 153 |
+
except Exception as err:
|
| 154 |
+
st.error(f"Unexpected exception {err}")
|
| 155 |
+
raise Exception(err) # but not this, let's crash the app
|
| 156 |
+
|
| 157 |
st.write(f'Welcome *{st.session_state["name"]}*')
|
| 158 |
st.title(
|
| 159 |
"You logged in! You can choose a session in the bottom of the sidebar and view content."
|
|
|
|
| 166 |
st.error("Username/password is incorrect")
|
| 167 |
elif st.session_state["authentication_status"] is None:
|
| 168 |
st.warning("Please enter your username and password")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|