I am trying to pass variables from my angular frontend to my python/tornado backend. Here is my code.
// JS
var columns = ["col_A", "col_B", "col_C"];
var url = "working url, I confirmed it hits the server before I tried passing parameters";
var req = {
method: "GET",
headers: {
'Content-Type': undefined
},
data: {
"columns": columns
}
}
return $http.get(url, req);
/*
I also tried
var req = {
url: url,
method: "GET",
headers: {
'Content-Type': undefined
},
data: {
"columns": columns
}
}
$http.get(req);
but got a 404 with this
*/
---------------------------------------------------------------------------------------------
## python
import tornado.web
import tornado.gen as gen
class MyRequestHandler(tornado.web.RequestHandler):
def __init__(self, *args, **kwargs):
super(MyRequestHandler, self).__init__(*args, **kwargs)
@gen.coroutine
def get(self, *args, **kwargs):
import pdb
pdb.set_trace()
# ... rest of the get function
## later on
http = tornado.web.Application([
(r"/working route", MyRequestHandler, {}),
... etc
So after my code pauses with the pdb.set_trace() statement to debug, I take a look at the variables. Looking at self.request, I see a bunch of possibly relevant stuff to my request (protocol, host, headers, etc) but I can't figure out how to get access to the parameter "columns". I tried
print self.get_argument("columns")
and got a 404. I'm really stumped. What am I doing wrong with this setup? I'm thinking this must be possible and I've just missed something really stupid.