I am having problem in calling a python function with angularjs $http request. I am having a python function which is on server like this
import cgi, cgitb
data= cgi.FieldStorage()
name = data.getvalue("name");
age = data.getvalue("age");
def printinfo( name, age ):
print "Name: ", name
print "Age ", age
return name,age
and i've also included cgi and my javascript code is
angular.module('app1',[])
.controller('ctrl',['$scope','$http' ,function ($scope,$http) {
$scope.bin = 'examp';
$scope.go = function () {
var url = "http://localhost/dump/test/test.py";
var bad =$http({
url :url ,
method:'POST',
data:{"name":"kumar" , "age":21}
}).success(function(data){
alert("working");
});
}
}])
and my javascript code is able to make a call to http://localhost/dump/test/test.py but it is shown as a document even when i included cgi in it .. Please guide me and also can you guys tell me is it the right way to send the values to server ie can i invoke the function print info by just sending name and age or should i send the function name too. If yes let me know how can i pass it ..
Thanks in advance..