How does python handle ajax post requests

$.ajax({
  type: "POST",
  url: /cgi-bin/getname.py,
  data: "{"name":"Jack"}",
  dataType: "json",
  success:function(result) {
    console.log(result);
  }
});

for example, the above code sends a request directly to the background. How to use Python to capture json data?
my cgi.FieldStorage (). Getvalue ("name") does not work properly

Apr.11,2022
What is written by

getname.py?


request.body


when I use the Tornado framework, I can get parameters directly using the following code:

 page_size = int(self.get_argument('page_size', 10))
 page_num = int(self.get_argument('page_num', 1))
 

as for your way of obtaining parameters, it is recommended to post part of the logic code in getname.py before you know it.

Menu