fix of the json upload format
This commit is contained in:
@@ -11860,7 +11860,12 @@ def batch_upload_page():
|
|||||||
return render_template('upload_batch.html')
|
return render_template('upload_batch.html')
|
||||||
|
|
||||||
|
|
||||||
|
from flask_wtf.csrf import CSRFProtect
|
||||||
|
csrf = CSRFProtect(app)
|
||||||
|
|
||||||
|
|
||||||
@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.
|
||||||
|
|||||||
@@ -165,14 +165,17 @@
|
|||||||
|
|
||||||
const formData = new FormData(form);
|
const formData = new FormData(form);
|
||||||
|
|
||||||
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
|
|
||||||
|
|
||||||
const fetchOptions = {
|
const fetchOptions = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
credentials: 'include'
|
credentials: 'include',
|
||||||
|
headers: {
|
||||||
|
'X-Requested-With': 'XMLHttpRequest'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
|
||||||
|
|
||||||
if (csrfToken) {
|
if (csrfToken) {
|
||||||
fetchOptions.headers = {
|
fetchOptions.headers = {
|
||||||
'X-CSRFToken': csrfToken
|
'X-CSRFToken': csrfToken
|
||||||
|
|||||||
Reference in New Issue
Block a user