新增功能:支持单独删除分析列表中的文件
This commit is contained in:
@@ -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():
|
||||
"""清理上传的文件(立即清理)"""
|
||||
|
||||
Reference in New Issue
Block a user