I'm trying to post some data with an ajax post request and execute a python file, retrieving the data in the python file, and return a result.
I have the following ajax code
$(function () {$("#upload").on("click", function (e) {$.ajax({type: 'post',url: "test1.py",data: {'param1':'abc'},async: false,success: function (response) {console.log(response);}}).done(function (data) {console.log(data);});});});
And the following python file
#! /usr/bin/pythonfrom __future__ import print_functionimport cgi, cgitbdef index():data = cgi.FieldStorage()mydata = data['param1'].valuereturn return "test"
I'm getting a keyerror on param1 -> "KeyError: 'param1'". I've also tried to use getValue(data['param1']. It looks like a problem with transferring the data from the ajax call to the python file i want to execute... But i can't figure out why.
Thanks in advance