Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +26 -0
src/streamlit_app.py
CHANGED
|
@@ -7,6 +7,32 @@ import joblib
|
|
| 7 |
from sklearn.ensemble import RandomForestClassifier
|
| 8 |
from sklearn.model_selection import train_test_split
|
| 9 |
from sklearn.metrics import classification_report, accuracy_score
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
MODEL_FILENAME = "/tmp/insurance_churn_model.pkl"
|
|
|
|
| 7 |
from sklearn.ensemble import RandomForestClassifier
|
| 8 |
from sklearn.model_selection import train_test_split
|
| 9 |
from sklearn.metrics import classification_report, accuracy_score
|
| 10 |
+
import streamlit_authenticator as stauth
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# --- Hardcoded credentials ---
|
| 15 |
+
USER_CREDENTIALS = {
|
| 16 |
+
"admin": "admin123",
|
| 17 |
+
"akshay": "user123"
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
# --- Login Panel ---
|
| 21 |
+
st.set_page_config(page_title="Login Panel", layout="centered")
|
| 22 |
+
st.markdown("<h2 style='text-align: center;'>🔐 Login Panel</h2>", unsafe_allow_html=True)
|
| 23 |
+
|
| 24 |
+
with st.form("login_form", clear_on_submit=False):
|
| 25 |
+
username = st.text_input("Username")
|
| 26 |
+
password = st.text_input("Password", type="password")
|
| 27 |
+
login_btn = st.form_submit_button("Login")
|
| 28 |
+
|
| 29 |
+
if login_btn:
|
| 30 |
+
if username in USER_CREDENTIALS and USER_CREDENTIALS[username] == password:
|
| 31 |
+
st.success(f"✅ Welcome, {username}!")
|
| 32 |
+
st.write("🎉 You are now logged in. Your app content goes here.")
|
| 33 |
+
else:
|
| 34 |
+
st.error("❌ Invalid username or password")
|
| 35 |
+
|
| 36 |
|
| 37 |
|
| 38 |
MODEL_FILENAME = "/tmp/insurance_churn_model.pkl"
|