Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,27 +39,25 @@
|
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
-
|
| 43 |
import streamlit as st
|
| 44 |
import json
|
| 45 |
import os
|
| 46 |
|
| 47 |
-
|
| 48 |
def load_feedback(filename):
|
| 49 |
-
if os.path.exists(filename) and os.stat(filename).st_size > 0:
|
| 50 |
with open(filename, 'r') as file:
|
| 51 |
return json.load(file)
|
| 52 |
else:
|
| 53 |
return {'thumbs_up': 0, 'thumbs_down': 0, 'comments': []}
|
| 54 |
|
| 55 |
-
|
| 56 |
-
# Function to save feedback to a JSON file
|
| 57 |
def save_feedback(feedback, filename):
|
| 58 |
with open(filename, 'w') as file:
|
| 59 |
json.dump(feedback, file)
|
| 60 |
|
| 61 |
# File to store feedback
|
| 62 |
-
|
|
|
|
|
|
|
| 63 |
|
| 64 |
# Load existing feedback
|
| 65 |
feedback = load_feedback(feedback_filename)
|
|
@@ -90,3 +88,4 @@ st.write(f"👎 Thumbs Down: {feedback['thumbs_down']}")
|
|
| 90 |
st.write("Comments:")
|
| 91 |
for c in feedback['comments']:
|
| 92 |
st.write(c)
|
|
|
|
|
|
| 39 |
|
| 40 |
|
| 41 |
|
|
|
|
| 42 |
import streamlit as st
|
| 43 |
import json
|
| 44 |
import os
|
| 45 |
|
|
|
|
| 46 |
def load_feedback(filename):
|
| 47 |
+
if os.path.exists(filename) and os.stat(filename).st_size > 0:
|
| 48 |
with open(filename, 'r') as file:
|
| 49 |
return json.load(file)
|
| 50 |
else:
|
| 51 |
return {'thumbs_up': 0, 'thumbs_down': 0, 'comments': []}
|
| 52 |
|
|
|
|
|
|
|
| 53 |
def save_feedback(feedback, filename):
|
| 54 |
with open(filename, 'w') as file:
|
| 55 |
json.dump(feedback, file)
|
| 56 |
|
| 57 |
# File to store feedback
|
| 58 |
+
# Set the directory path within your Hugging Face Space
|
| 59 |
+
# Example: "/mnt/data/feedback.json"
|
| 60 |
+
feedback_filename = "/mnt/data/feedback.json"
|
| 61 |
|
| 62 |
# Load existing feedback
|
| 63 |
feedback = load_feedback(feedback_filename)
|
|
|
|
| 88 |
st.write("Comments:")
|
| 89 |
for c in feedback['comments']:
|
| 90 |
st.write(c)
|
| 91 |
+
|