diff --git a/Web/app.py b/Web/app.py index 7541c85..b2e7395 100755 --- a/Web/app.py +++ b/Web/app.py @@ -11863,8 +11863,8 @@ def batch_upload_page(): return render_template('upload_batch.html') + @app.route('/upload_csv_batch', methods=['POST']) -@csrf.exempt def upload_csv_batch(): """ Route for batch adding new items to the inventory via CSV. diff --git a/Web/templates/upload_batch.html b/Web/templates/upload_batch.html index 9f37a79..2a3dcb6 100644 --- a/Web/templates/upload_batch.html +++ b/Web/templates/upload_batch.html @@ -127,6 +127,7 @@ padding-bottom: 0; } + @@ -272,11 +273,15 @@ document.getElementById('batchUploadForm').addEventListener('submit', async func formData.append('images', img); }); - // An Server senden try { + const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content'); + const response = await fetch('/upload_csv_batch', { method: 'POST', - body: formData + body: formData, + headers: { + 'X-CSRFToken': csrfToken + } }); const result = await response.json();