Trae Assistant commited on
Commit ·
71bca6f
1
Parent(s): cefc0f7
Localization: Update error messages to Chinese
Browse files
app.py
CHANGED
|
@@ -153,7 +153,7 @@ def analyze():
|
|
| 153 |
try:
|
| 154 |
data = request.json
|
| 155 |
if not data:
|
| 156 |
-
return jsonify({'success': False, 'error': '
|
| 157 |
|
| 158 |
# 获取参数,提供默认值
|
| 159 |
cost = float(data.get('cost', 10.0))
|
|
@@ -181,11 +181,11 @@ def upload_file():
|
|
| 181 |
"""
|
| 182 |
try:
|
| 183 |
if 'file' not in request.files:
|
| 184 |
-
return jsonify({'success': False, 'error': '
|
| 185 |
|
| 186 |
file = request.files['file']
|
| 187 |
if file.filename == '':
|
| 188 |
-
return jsonify({'success': False, 'error': '
|
| 189 |
|
| 190 |
if file:
|
| 191 |
filename = secure_filename(file.filename)
|
|
@@ -199,9 +199,9 @@ def upload_file():
|
|
| 199 |
elif filename.endswith(('.xls', '.xlsx')):
|
| 200 |
df = pd.read_excel(filepath)
|
| 201 |
else:
|
| 202 |
-
return jsonify({'success': False, 'error': '
|
| 203 |
except Exception as e:
|
| 204 |
-
return jsonify({'success': False, 'error': f'
|
| 205 |
|
| 206 |
# 检查必需列
|
| 207 |
required_cols = ['cost', 'base_price', 'base_demand']
|
|
@@ -248,7 +248,7 @@ def upload_file():
|
|
| 248 |
|
| 249 |
except Exception as e:
|
| 250 |
logger.error(f"Upload Error: {str(e)}")
|
| 251 |
-
return jsonify({'success': False, 'error': str(e)}), 500
|
| 252 |
|
| 253 |
if __name__ == '__main__':
|
| 254 |
port = int(os.environ.get('PORT', 7860))
|
|
|
|
| 153 |
try:
|
| 154 |
data = request.json
|
| 155 |
if not data:
|
| 156 |
+
return jsonify({'success': False, 'error': '未提供数据'}), 400
|
| 157 |
|
| 158 |
# 获取参数,提供默认值
|
| 159 |
cost = float(data.get('cost', 10.0))
|
|
|
|
| 181 |
"""
|
| 182 |
try:
|
| 183 |
if 'file' not in request.files:
|
| 184 |
+
return jsonify({'success': False, 'error': '未找到上传文件'}), 400
|
| 185 |
|
| 186 |
file = request.files['file']
|
| 187 |
if file.filename == '':
|
| 188 |
+
return jsonify({'success': False, 'error': '未选择文件'}), 400
|
| 189 |
|
| 190 |
if file:
|
| 191 |
filename = secure_filename(file.filename)
|
|
|
|
| 199 |
elif filename.endswith(('.xls', '.xlsx')):
|
| 200 |
df = pd.read_excel(filepath)
|
| 201 |
else:
|
| 202 |
+
return jsonify({'success': False, 'error': '不支持的文件格式 (仅支持 .csv, .xls, .xlsx)'}), 400
|
| 203 |
except Exception as e:
|
| 204 |
+
return jsonify({'success': False, 'error': f'文件读取错误: {str(e)}'}), 400
|
| 205 |
|
| 206 |
# 检查必需列
|
| 207 |
required_cols = ['cost', 'base_price', 'base_demand']
|
|
|
|
| 248 |
|
| 249 |
except Exception as e:
|
| 250 |
logger.error(f"Upload Error: {str(e)}")
|
| 251 |
+
return jsonify({'success': False, 'error': f"服务器内部错误: {str(e)}"}), 500
|
| 252 |
|
| 253 |
if __name__ == '__main__':
|
| 254 |
port = int(os.environ.get('PORT', 7860))
|