Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -927,61 +927,67 @@ if query:
|
|
927 |
st.markdown("---")
|
928 |
|
929 |
|
930 |
-
|
931 |
|
932 |
-
|
933 |
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
|
|
|
|
939 |
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
|
945 |
-
|
946 |
-
|
947 |
|
948 |
-
|
949 |
|
950 |
-
|
951 |
-
|
952 |
|
953 |
-
|
954 |
"(app will pause while we save your comments)")
|
955 |
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
|
963 |
-
|
|
|
964 |
dataset = Dataset.load_from_disk('comments')
|
|
|
|
|
965 |
|
966 |
-
|
967 |
-
|
968 |
|
969 |
-
|
970 |
-
|
971 |
|
972 |
-
|
973 |
-
|
974 |
|
975 |
-
|
976 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
977 |
|
978 |
-
# Display the comments if the password is correct
|
979 |
-
if password == PASSWORD:
|
980 |
-
st.title('Comments')
|
981 |
-
for comment in comments:
|
982 |
-
st.write(comment)
|
983 |
-
else:
|
984 |
-
st.warning('Incorrect password')
|
985 |
|
986 |
|
987 |
st.markdown("---")
|
|
|
927 |
st.markdown("---")
|
928 |
|
929 |
|
930 |
+
import os
|
931 |
|
932 |
+
from datasets import Dataset
|
933 |
|
934 |
+
# Check if the comments directory exists
|
935 |
+
if os.path.exists('comments'):
|
936 |
+
# Load the dataset from disk
|
937 |
+
dataset = Dataset.load_from_disk('comments')
|
938 |
+
else:
|
939 |
+
# Create a new dataset
|
940 |
+
dataset = Dataset.from_dict({'id': [], 'text': []})
|
941 |
|
942 |
+
def save_comment(comment):
|
943 |
+
# Add the comment to the dataset
|
944 |
+
dataset['id'].append(len(dataset))
|
945 |
+
dataset['text'].append(comment)
|
946 |
|
947 |
+
# Save the dataset to disk
|
948 |
+
dataset.save_to_disk('comments')
|
949 |
|
950 |
+
print('Comment saved to dataset.')
|
951 |
|
952 |
+
st.title("Abstractalytics Web App")
|
953 |
+
st.write("We appreciate your feedback!")
|
954 |
|
955 |
+
user_comment = st.text_area("Please send us your anonymous remarks/suggestions about the Abstractalytics Web App: "
|
956 |
"(app will pause while we save your comments)")
|
957 |
|
958 |
+
if st.button("Submit"):
|
959 |
+
if user_comment:
|
960 |
+
save_comment(user_comment)
|
961 |
+
st.success("Your comment has been saved. Thank you for your feedback!")
|
962 |
+
else:
|
963 |
+
st.warning("Please enter a comment before submitting.")
|
964 |
|
965 |
+
# Load the comments dataset from disk
|
966 |
+
if os.path.exists('comments'):
|
967 |
dataset = Dataset.load_from_disk('comments')
|
968 |
+
else:
|
969 |
+
dataset = Dataset.from_dict({'id': [], 'text': []})
|
970 |
|
971 |
+
# Access the text column of the dataset
|
972 |
+
comments = dataset['text']
|
973 |
|
974 |
+
# Define the password
|
975 |
+
PASSWORD = 'ram100pass'
|
976 |
|
977 |
+
# Create a Streamlit app
|
978 |
+
st.set_page_config(page_title='Comments')
|
979 |
|
980 |
+
# Prompt the user for the password
|
981 |
+
password = st.text_input('Password:', type='password')
|
982 |
+
|
983 |
+
# Display the comments if the password is correct
|
984 |
+
if password == PASSWORD:
|
985 |
+
st.title('Comments')
|
986 |
+
for comment in comments:
|
987 |
+
st.write(comment)
|
988 |
+
else:
|
989 |
+
st.warning('Incorrect password')
|
990 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
991 |
|
992 |
|
993 |
st.markdown("---")
|