fix of the json upload format

This commit is contained in:
2026-08-04 20:44:15 +02:00
parent 88f124c991
commit 91ddc6e864
2 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -11863,8 +11863,8 @@ def batch_upload_page():
return render_template('upload_batch.html') return render_template('upload_batch.html')
@app.route('/upload_csv_batch', methods=['POST']) @app.route('/upload_csv_batch', methods=['POST'])
@csrf.exempt
def upload_csv_batch(): def upload_csv_batch():
""" """
Route for batch adding new items to the inventory via CSV. Route for batch adding new items to the inventory via CSV.
+7 -2
View File
@@ -127,6 +127,7 @@
padding-bottom: 0; padding-bottom: 0;
} }
</style> </style>
<meta name="csrf-token" content="{{ csrf_token() }}">
</head> </head>
<body> <body>
@@ -272,11 +273,15 @@ document.getElementById('batchUploadForm').addEventListener('submit', async func
formData.append('images', img); formData.append('images', img);
}); });
// An Server senden
try { try {
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
const response = await fetch('/upload_csv_batch', { const response = await fetch('/upload_csv_batch', {
method: 'POST', method: 'POST',
body: formData body: formData,
headers: {
'X-CSRFToken': csrfToken
}
}); });
const result = await response.json(); const result = await response.json();