0

I am using angularjs to pass the data to back end(python flask)

var currenttopic = "All";
    $http.post("/CA/"currenttopic,date).success(function(response){
                console.log(response);
            });

and in backend the python flask code is something like

@app.route('/CA/<topic>', methods=['POST'])
@login_required
def competitivepertopic(topic):
    if request.method == 'POST':
        print(topic)
        data = request.get_json()
        pass
    return json.dumps({'data': topic})

now how can i pass currenttopic variable to backend?

1 Answers1

2

Try it like this:

$http.post("/CA/" + currenttopic, date).success(function(response) {

or with ES6:

$http.post(`/CA/${currenttopic}`, date).success(function(response) {
Andrei Roba
  • 2,156
  • 2
  • 16
  • 33