fix: Restore missing code in delete_image and get_gallery

This commit is contained in:
Khoa.vo 2025-12-30 19:41:57 +07:00
parent 931eb72b14
commit 7376050da7

7
app.py
View file

@ -761,7 +761,14 @@ def delete_image():
if os.path.exists(filepath):
try:
send2trash(filepath)
return jsonify({'success': True, 'source': resolved_source})
except Exception as e:
return jsonify({'error': str(e)}), 500
else:
return jsonify({'error': 'File not found'}), 404
@app.route('/gallery')
def get_gallery():
# List all images in the chosen source directory, sorted by modification time (newest first)
source_param = (request.args.get('source') or 'generated').lower()
base_dir = UPLOADS_DIR if source_param == 'uploads' else GENERATED_DIR