2017-10-27 10 views
-1

私は(Pythonのフラスコ)バックエンドでの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}) 
のようなものが

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

とあるバックエンドにデータを渡すangularjsを使用していますPythonのフラスコに、URLに変数を渡します

どうすればcurrenttopic変数をバックエンドに渡すことができますか?

+0

別の質問 –

答えて

2

このようにそれを試してみてください。

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

またはES6と:

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

であることは、チルダ記号のですか? –

+0

最初の行が私のために働いた。助けてくれてありがとう –