Spaces:
Running
Running
gabrielaltay
commited on
Commit
•
f693380
1
Parent(s):
0b63397
passwords
Browse files- .gitignore +1 -0
- app.py +29 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.streamlit
|
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import os
|
2 |
import tempfile
|
3 |
|
@@ -15,6 +16,34 @@ from torch.utils.data import DataLoader
|
|
15 |
from transformers import AutoProcessor
|
16 |
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
19 |
SS = st.session_state
|
20 |
|
|
|
1 |
+
import hmac
|
2 |
import os
|
3 |
import tempfile
|
4 |
|
|
|
16 |
from transformers import AutoProcessor
|
17 |
|
18 |
|
19 |
+
def check_password():
|
20 |
+
"""Returns `True` if the user had the correct password."""
|
21 |
+
|
22 |
+
def password_entered():
|
23 |
+
"""Checks whether a password entered by the user is correct."""
|
24 |
+
if hmac.compare_digest(st.session_state["password"], st.secrets["password"]):
|
25 |
+
st.session_state["password_correct"] = True
|
26 |
+
del st.session_state["password"] # Don't store the password.
|
27 |
+
else:
|
28 |
+
st.session_state["password_correct"] = False
|
29 |
+
|
30 |
+
# Return True if the password is validated.
|
31 |
+
if st.session_state.get("password_correct", False):
|
32 |
+
return True
|
33 |
+
|
34 |
+
# Show input for password.
|
35 |
+
st.text_input(
|
36 |
+
"Password", type="password", on_change=password_entered, key="password"
|
37 |
+
)
|
38 |
+
if "password_correct" in st.session_state:
|
39 |
+
st.error("😕 Password incorrect")
|
40 |
+
return False
|
41 |
+
|
42 |
+
|
43 |
+
if not check_password():
|
44 |
+
st.stop() # Do not continue if check_password is not True.
|
45 |
+
|
46 |
+
|
47 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
48 |
SS = st.session_state
|
49 |
|