新增功能:支持单独删除分析列表中的文件

This commit is contained in:
2026-01-11 11:49:44 +08:00
parent 223d4859d1
commit 463573235b
3 changed files with 75 additions and 2 deletions
+19
View File
@@ -129,6 +129,25 @@ def upload_file():
return jsonify({'error': '不支持的文件格式'}), 400
@app.route('/delete/<filename>', methods=['POST'])
def delete_file(filename):
"""删除指定的单个文件"""
try:
filename = secure_filename(filename)
upload_folder = app.config['UPLOAD_FOLDER']
filepath = os.path.join(upload_folder, filename)
if os.path.exists(filepath):
os.remove(filepath)
return jsonify({
'success': True,
'message': f'文件 {filename} 已成功删除'
})
else:
return jsonify({'error': '文件不存在'}), 404
except Exception as e:
return jsonify({'error': f'删除文件失败: {str(e)}'}), 500
@app.route('/cleanup', methods=['POST'])
def cleanup_files():
"""清理上传的文件(立即清理)"""