jfataphd commited on
Commit
d2396af
1 Parent(s): 7706550

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -4
app.py CHANGED
@@ -926,17 +926,29 @@ if query:
926
  st.markdown("---")
927
 
928
 
 
 
 
 
 
 
 
 
929
  def save_comment(comment):
930
- with open('comments.txt', 'a') as f:
931
- f.write(f'{comment}\n')
932
- print('Comment saved to file.')
933
 
 
 
 
 
934
 
935
  st.title("Abstractalytics Web App")
936
  st.write("We appreciate your feedback!")
937
 
938
  user_comment = st.text_area("Please send us your anonymous remarks/suggestions about the Abstractalytics Web App: "
939
- "(app will pause while we save your comments)")
940
 
941
  if st.button("Submit"):
942
  if user_comment:
@@ -945,6 +957,30 @@ if query:
945
  else:
946
  st.warning("Please enter a comment before submitting.")
947
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
948
  st.markdown("---")
949
 
950
  st.subheader("Cancer-related videos")
 
926
  st.markdown("---")
927
 
928
 
929
+ from datasets import Dataset
930
+
931
+ # Load existing comments or create a new dataset
932
+ if Dataset.get_dataset_infos('comments'):
933
+ dataset = Dataset.load_from_disk('comments')
934
+ else:
935
+ dataset = Dataset.from_dict({'id': [], 'text': []})
936
+
937
  def save_comment(comment):
938
+ # Add the comment to the dataset
939
+ dataset['id'].append(len(dataset))
940
+ dataset['text'].append(comment)
941
 
942
+ # Save the dataset to disk
943
+ dataset.save_to_disk('comments')
944
+
945
+ print('Comment saved to dataset.')
946
 
947
  st.title("Abstractalytics Web App")
948
  st.write("We appreciate your feedback!")
949
 
950
  user_comment = st.text_area("Please send us your anonymous remarks/suggestions about the Abstractalytics Web App: "
951
+ "(app will pause while we save your comments)")
952
 
953
  if st.button("Submit"):
954
  if user_comment:
 
957
  else:
958
  st.warning("Please enter a comment before submitting.")
959
 
960
+ # Load the comments dataset from disk
961
+ dataset = Dataset.load_from_disk('comments')
962
+
963
+ # Access the text column of the dataset
964
+ comments = dataset['text']
965
+
966
+ # Define the password
967
+ PASSWORD = 'ram100pass'
968
+
969
+ # Create a Streamlit app
970
+ st.set_page_config(page_title='Comments')
971
+
972
+ # Prompt the user for the password
973
+ password = st.text_input('Password:', type='password')
974
+
975
+ # Display the comments if the password is correct
976
+ if password == PASSWORD:
977
+ st.title('Comments')
978
+ for comment in comments:
979
+ st.write(comment)
980
+ else:
981
+ st.warning('Incorrect password')
982
+
983
+
984
  st.markdown("---")
985
 
986
  st.subheader("Cancer-related videos")