我正在使用 AngularJS 将数据传递到后端(Python Flask)
var currenttopic = "All";
$http.post("/CA/"currenttopic,date).success(function(response){
console.log(response);
});
在后端,Python Flask 代码类似于
@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})
现在我如何将当前主题变量传递到后端?
最佳答案
尝试这样:
$http.post("/CA/" + currenttopic, date).success(function(response) {
或者使用 ES6:
$http.post(`/CA/${currenttopic}`, date).success(function(response) {
关于javascript - 如何将url中的变量传递给pythonflask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46969118/