Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,14 +44,15 @@ import streamlit as st
|
|
| 44 |
import json
|
| 45 |
import os
|
| 46 |
|
| 47 |
-
|
| 48 |
def load_feedback(filename):
|
| 49 |
-
if os.path.exists(filename):
|
| 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 |
# Function to save feedback to a JSON file
|
| 56 |
def save_feedback(feedback, filename):
|
| 57 |
with open(filename, 'w') as file:
|
|
|
|
| 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: # Check if file exists and is not empty
|
| 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:
|