Spaces:
Running
Running
Commit
·
cf367e2
1
Parent(s):
663a6db
Password protection?
Browse files- .gitignore +1 -0
- app.py +25 -2
- requirements.txt +2 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
env/
|
app.py
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
import streamlit as st
|
| 3 |
+
import dotenv
|
| 4 |
|
| 5 |
+
dotenv.load_dotenv()
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
PASSWORD = os.getenv("APP_PASSWORD")
|
| 9 |
+
|
| 10 |
+
if "authenticated" not in st.session_state:
|
| 11 |
+
st.session_state.authenticated = False
|
| 12 |
+
|
| 13 |
+
if not st.session_state.authenticated:
|
| 14 |
+
password = st.text_input("Password", type="password")
|
| 15 |
+
if st.button("Login"):
|
| 16 |
+
if password == PASSWORD:
|
| 17 |
+
st.session_state.authenticated = True
|
| 18 |
+
else:
|
| 19 |
+
st.error("Invalid credentials")
|
| 20 |
+
|
| 21 |
+
if st.session_state.authenticated:
|
| 22 |
+
st.success("Logged in successfully!")
|
| 23 |
+
# Your app content here
|
| 24 |
+
|
| 25 |
+
st.write("Hello, world!")
|
| 26 |
+
else:
|
| 27 |
+
st.warning("Please log in to access this app.")
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
python-dotenv
|