jfataphd commited on
Commit
603e5d4
·
1 Parent(s): 8b30702

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -39
app.py CHANGED
@@ -927,61 +927,67 @@ if query:
927
  st.markdown("---")
928
 
929
 
930
- import os
931
 
932
- from datasets import Dataset
933
 
934
- # Load existing comments or create a new dataset
935
- if os.path.exists('comments'):
936
- dataset = Dataset.load_from_disk('comments')
937
- else:
938
- dataset = Dataset.from_dict({'id': [], 'text': []})
 
 
939
 
940
- def save_comment(comment):
941
- # Add the comment to the dataset
942
- dataset['id'].append(len(dataset))
943
- dataset['text'].append(comment)
944
 
945
- # Save the dataset to disk
946
- dataset.save_to_disk('comments')
947
 
948
- print('Comment saved to dataset.')
949
 
950
- st.title("Abstractalytics Web App")
951
- st.write("We appreciate your feedback!")
952
 
953
- user_comment = st.text_area("Please send us your anonymous remarks/suggestions about the Abstractalytics Web App: "
954
  "(app will pause while we save your comments)")
955
 
956
- if st.button("Submit"):
957
- if user_comment:
958
- save_comment(user_comment)
959
- st.success("Your comment has been saved. Thank you for your feedback!")
960
- else:
961
- st.warning("Please enter a comment before submitting.")
962
 
963
- # Load the comments dataset from disk
 
964
  dataset = Dataset.load_from_disk('comments')
 
 
965
 
966
- # Access the text column of the dataset
967
- comments = dataset['text']
968
 
969
- # Define the password
970
- PASSWORD = 'ram100pass'
971
 
972
- # Create a Streamlit app
973
- st.set_page_config(page_title='Comments')
974
 
975
- # Prompt the user for the password
976
- password = st.text_input('Password:', type='password')
 
 
 
 
 
 
 
 
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("---")