Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,29 @@ from oauth2client.service_account import ServiceAccountCredentials
|
|
4 |
import gradio as gr
|
5 |
import plotly.express as px
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
# === Google Sheets Auth ===
|
8 |
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
|
9 |
creds = ServiceAccountCredentials.from_json_keyfile_name("tough-star.json", scope)
|
|
|
4 |
import gradio as gr
|
5 |
import plotly.express as px
|
6 |
|
7 |
+
# ------------------ Authentication ------------------
|
8 |
+
VALID_USERS = {
|
9 |
+
"CarfindAdmin": "Pass.123",
|
10 |
+
}
|
11 |
+
|
12 |
+
def login():
|
13 |
+
st.title("🔐 Login Required")
|
14 |
+
email = st.text_input("Email")
|
15 |
+
password = st.text_input("Password", type="password")
|
16 |
+
if st.button("Login"):
|
17 |
+
if VALID_USERS.get(email) == password:
|
18 |
+
st.session_state.authenticated = True
|
19 |
+
st.rerun()
|
20 |
+
else:
|
21 |
+
st.error("❌ Incorrect email or password.")
|
22 |
+
|
23 |
+
if "authenticated" not in st.session_state:
|
24 |
+
st.session_state.authenticated = False
|
25 |
+
|
26 |
+
if not st.session_state.authenticated:
|
27 |
+
login()
|
28 |
+
st.stop()
|
29 |
+
|
30 |
# === Google Sheets Auth ===
|
31 |
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
|
32 |
creds = ServiceAccountCredentials.from_json_keyfile_name("tough-star.json", scope)
|