I am converting an already existing http.get request to a http.post request due to security reasons. even though the code i have written is working, i dont think it is very robust. Is there a better way to define the data object?
I would prefer sending a dictionary and reading it in the back end.
Sample code goes as below.
http.get("/ajax/validate_login.py",{params:{"email":$scope.userEmail,"password":$scope.password}}).then(function(response) {
console.log(response);
});
is converted to
$http({ method: 'POST', url: '/ajax/validate_login.py?',
data: 'email=' + $scope.userEmail + '&password=' + $scope.password ,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).then(function(response) {
console.log(response);
});
is there a better way to define data in post request ?
Back end code is as below
#!/usr/bin/python
import cgi
import json
import MySQLdb
import MySQLdb.cursors
import hashlib
import sys
form = cgi.FieldStorage()
email=form["email"].value
password = form["password"].value
print "Content-Type: application/json"
print