Commit ·
2a8b4dc
1
Parent(s): 12bb6d1
Disable history and cleanup immediately
Browse files- backend/app.py +7 -20
backend/app.py
CHANGED
|
@@ -229,27 +229,14 @@ def predict():
|
|
| 229 |
if result is None:
|
| 230 |
return jsonify({'error': error}), 500
|
| 231 |
|
| 232 |
-
#
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
# We need to read the file again or just copy if we haven't deleted it?
|
| 239 |
-
# We read via cv2, the file is still at filepath.
|
| 240 |
-
shutil.copy(filepath, history_path)
|
| 241 |
|
| 242 |
-
|
| 243 |
-
relative_path = f"history_uploads/{history_filename}"
|
| 244 |
-
|
| 245 |
-
database.add_scan(
|
| 246 |
-
filename=filename,
|
| 247 |
-
prediction=result['prediction'],
|
| 248 |
-
confidence=result['confidence'],
|
| 249 |
-
fake_prob=result['fake_probability'],
|
| 250 |
-
real_prob=result['real_probability'],
|
| 251 |
-
image_path=relative_path
|
| 252 |
-
)
|
| 253 |
|
| 254 |
# Clean up uploaded file
|
| 255 |
try:
|
|
|
|
| 229 |
if result is None:
|
| 230 |
return jsonify({'error': error}), 500
|
| 231 |
|
| 232 |
+
# Cleanup - Delete the upload immediately
|
| 233 |
+
try:
|
| 234 |
+
if os.path.exists(filepath):
|
| 235 |
+
os.remove(filepath)
|
| 236 |
+
except:
|
| 237 |
+
pass
|
|
|
|
|
|
|
|
|
|
| 238 |
|
| 239 |
+
return jsonify(result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
|
| 241 |
# Clean up uploaded file
|
| 242 |
try:
|