我正在使用 angularjs 将数据传递到后端(python 烧瓶)
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 变量传递给后端?
像这样尝试:
$http.post("/CA/" + currenttopic, date).success(function(response) {
或使用 ES6:
$http.post(`/CA/${currenttopic}`, date).success(function(response) {
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句