Это первый раз, когда я пытаюсь передать данные от Json до flask, но я получаю эту ошибку. :5000/_get_post_json/:1 Failed to load resource: the server responded with a status of 400 (BAD REQUEST)
@app.route('/_get_post_json/', methods=['POST'])
def get_post_json():
data = request.get_json()
print(data)
return jsonify(status="success", data=data)
var origin1 = $('#origin-input').val();
var destination1 = $('#destination-input').val();
window.drivername = `${data.firstname}`;
$.ajax({
type: "POST",
url: "{{ url_for("get_post_json") }}",
contentType: "application/json",
data: { origin: origin1, destination: destination1, name: window.drivername },
dataType: "json",
success: function(response) {
console.log(response);
},
error: function(err) {
console.log(err);
}
});