Yes Mr. Whtesell. I was able to resolve the issue with the csrf middleware token by reading what you sent.
I wanted to ask how I could grab the value of facialImage
result inside the Django view which as you know, is written in Python.
The name of the JSON object being sent is facialImage
correct?
$.ajax({
url : URL,
type: "POST",
data: JSON.stringify({
// csrfmiddlewaretoken: document.getElementsByName('csrfmiddlewaretoken')[0].value,
/*Use stringify() method to convert 'facialImage' into a string,
so that it can be sent to the server.*/
// facialImage: JSON.stringify(facialImage),
facialImage,
}),
processData: false,
dataType : "json",
headers: {'X-CSRFToken': csrftoken},
mode: 'same-origin',
/*https://stackoverflow.com/questions/8614947/jquery-and-django-csrf-token*/
/*"success" is what happens when the server responds successfully
'response' is the response from the Django view (a json object).*/
success: function(response){
// $(".sendButton").
}
});
How can I grab facialImage
in the FacialLoginResult view?
def FacialLoginResult(request):
if request.method == 'POST':
print("Printing request.body")
# print(request.body)
# All of the data in a POST request will be stored inside
# the 'POST' dictionary.
body_unicode = request.body.decode('utf-8')
json_data = json.loads(body_unicode)
# facialImage = json_data['data']
# type_tiny = pyshorteners.Shortener()
# short_url = type_tiny.tinyurl.short(json_data)
print(short_url)