我正在使用angularjs将数据传递到后端(python flask)
var currenttopic = "All";
$http.post("/CA/"currenttopic,date).success(function(response){
console.log(response);
});
在后端,python烧瓶代码类似于
@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})
现在我如何将currenttopic变量传递给后端?
答案 0 :(得分:2)
试试这样:
$http.post("/CA/" + currenttopic, date).success(function(response) {
或与ES6:
$http.post(`/CA/${currenttopic}`, date).success(function(response) {