YashB1 commited on
Commit
0cd98a2
Β·
verified Β·
1 Parent(s): b80ba9e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -68
app.py CHANGED
@@ -1,82 +1,82 @@
1
- ################################################### Approach 1
2
- # import streamlit as st
3
- # import json
4
- # import os
5
-
6
- # # Function to load existing feedback from a JSON file
7
- # def load_feedback(filename):
8
- # if os.path.exists(filename):
9
- # with open(filename, 'r') as file:
10
- # return json.load(file)
11
- # else:
12
- # return {'thumbs_up': 0, 'thumbs_down': 0, 'comments': []}
13
-
14
- # # Function to save feedback to a JSON file
15
- # def save_feedback(feedback, filename):
16
- # with open(filename, 'w') as file:
17
- # json.dump(feedback, file)
18
-
19
- # # File to store feedback
20
- # feedback_filename = "feedback.json"
21
-
22
- # # Load existing feedback
23
- # feedback = load_feedback(feedback_filename)
24
-
25
- # # Display thumbs up/down buttons
26
- # if st.button("πŸ‘ Thumbs Up"):
27
- # feedback['thumbs_up'] += 1
28
- # save_feedback(feedback, feedback_filename)
29
- # st.success("Thanks for your feedback!")
30
-
31
- # if st.button("πŸ‘Ž Thumbs Down"):
32
- # feedback['thumbs_down'] += 1
33
- # save_feedback(feedback, feedback_filename)
34
- # st.error("We're sorry to hear that. Please reach out to us for further assistance.")
35
-
36
- # # Comments section
37
- # st.header("Comments")
38
- # comment = st.text_area("Leave your comment here:")
39
- # if st.button("Submit Comment"):
40
- # feedback['comments'].append(comment)
41
- # save_feedback(feedback, feedback_filename)
42
- # st.success("Your comment has been submitted!")
43
-
44
- # # Display current feedback
45
- # st.write("Current Feedback:")
46
- # st.write(f"πŸ‘ Thumbs Up: {feedback['thumbs_up']}")
47
- # st.write(f"πŸ‘Ž Thumbs Down: {feedback['thumbs_down']}")
48
- # st.write("Comments:")
49
- # for c in feedback['comments']:
50
- # st.write(c)
51
 
52
 
53
 
54
 
55
  ################################################### Approach 2
56
- import streamlit as st
57
 
58
- def collect_feedback():
59
- st.title("Feedback Collection App")
60
 
61
- # Display thumbs up/down buttons for feedback
62
- feedback = st.radio("Was this helpful?", ('πŸ‘', 'πŸ‘Ž'))
63
 
64
- # Text input for comments
65
- comments = st.text_area("Please provide any comments or suggestions:")
66
 
67
- if st.button("Submit"):
68
- if feedback == 'πŸ‘':
69
- st.success("Thank you for your positive feedback!")
70
- elif feedback == 'πŸ‘Ž':
71
- st.error("We're sorry to hear that. Please let us know how we can improve.")
72
 
73
- # Do something with the feedback and comments (e.g., save to a database)
74
- # For now, just print them
75
- st.write("Feedback:", feedback)
76
- st.write("Comments:", comments)
77
 
78
- if __name__ == "__main__":
79
- collect_feedback()
80
 
81
 
82
 
 
1
+ ################################################## Approach 1
2
+ import streamlit as st
3
+ import json
4
+ import os
5
+
6
+ # Function to load existing feedback from a JSON file
7
+ def load_feedback(filename):
8
+ if os.path.exists(filename):
9
+ with open(filename, 'r') as file:
10
+ return json.load(file)
11
+ else:
12
+ return {'thumbs_up': 0, 'thumbs_down': 0, 'comments': []}
13
+
14
+ # Function to save feedback to a JSON file
15
+ def save_feedback(feedback, filename):
16
+ with open(filename, 'w') as file:
17
+ json.dump(feedback, file)
18
+
19
+ # File to store feedback
20
+ feedback_filename = "feedback.json"
21
+
22
+ # Load existing feedback
23
+ feedback = load_feedback(feedback_filename)
24
+
25
+ # Display thumbs up/down buttons
26
+ if st.button("πŸ‘ Thumbs Up"):
27
+ feedback['thumbs_up'] += 1
28
+ save_feedback(feedback, feedback_filename)
29
+ st.success("Thanks for your feedback!")
30
+
31
+ if st.button("πŸ‘Ž Thumbs Down"):
32
+ feedback['thumbs_down'] += 1
33
+ save_feedback(feedback, feedback_filename)
34
+ st.error("We're sorry to hear that. Please reach out to us for further assistance.")
35
+
36
+ # Comments section
37
+ st.header("Comments")
38
+ comment = st.text_area("Leave your comment here:")
39
+ if st.button("Submit Comment"):
40
+ feedback['comments'].append(comment)
41
+ save_feedback(feedback, feedback_filename)
42
+ st.success("Your comment has been submitted!")
43
+
44
+ # Display current feedback
45
+ st.write("Current Feedback:")
46
+ st.write(f"πŸ‘ Thumbs Up: {feedback['thumbs_up']}")
47
+ st.write(f"πŸ‘Ž Thumbs Down: {feedback['thumbs_down']}")
48
+ st.write("Comments:")
49
+ for c in feedback['comments']:
50
+ st.write(c)
51
 
52
 
53
 
54
 
55
  ################################################### Approach 2
56
+ # import streamlit as st
57
 
58
+ # def collect_feedback():
59
+ # st.title("Feedback Collection App")
60
 
61
+ # # Display thumbs up/down buttons for feedback
62
+ # feedback = st.radio("Was this helpful?", ('πŸ‘', 'πŸ‘Ž'))
63
 
64
+ # # Text input for comments
65
+ # comments = st.text_area("Please provide any comments or suggestions:")
66
 
67
+ # if st.button("Submit"):
68
+ # if feedback == 'πŸ‘':
69
+ # st.success("Thank you for your positive feedback!")
70
+ # elif feedback == 'πŸ‘Ž':
71
+ # st.error("We're sorry to hear that. Please let us know how we can improve.")
72
 
73
+ # # Do something with the feedback and comments (e.g., save to a database)
74
+ # # For now, just print them
75
+ # st.write("Feedback:", feedback)
76
+ # st.write("Comments:", comments)
77
 
78
+ # if __name__ == "__main__":
79
+ # collect_feedback()
80
 
81
 
82