私は、anglejsフロントエンドを使用するフラスコアプリを持っています。 $ httpサービスを通じてhttpリクエストを行います。以下のコードに示すように。特定のルートに対して1つのフラスコ要求を許可する
$http.post('/updateGraph', $scope.graphingParameters).success(function(response) {
$scope.graphingParameters.graph = response.graph;
$scope.listUnits = JSON.parse(response.listUnits);
$scope.myHTML = $sce.trustAsHtml($scope.graphingParameters.graph);
$scope.showME = true;
})
フラスコ内のupdateGraph関数は次のとおりです。
@app.route('/updateGraph', methods = ['POST'])
def updateGraph():
selectValues = request.json['selectValues']
selectSelected = np.array(request.json['selectSelected']).tolist()
if len(selectSelected) == 0:
selectSelected = np.array([selectValues[1:3]]).tolist()
fig, listUnits = plot_Stock_vs_Sales(selectSelected)
graph = py_offline.plot(fig, include_plotlyjs=False, output_type='div', show_link=False)
return json.dumps({ 'graph': graph, 'listUnits':listUnits.reset_index().to_json(orient='records')})
問題は、$ http投稿を角度から2回作成するとします。フラスコのルートは2回実行されています。これはサーバーのコードです。
秒:92 127.0.0.1 - - [12/9月/ 2016午前9時46分35秒] "POST/updateGraph HTTP/1.1" 200 - 秒:110 127.0.0.1 - - [12/9月/ 2016午前9時47分02秒]「POST/updateGraph HTTP/1.1」200 -
私は1つの要求を許可またはフラスコは、ユーザーごとに1つだけのルートを実行させるだけに$のHTTP POSTリクエストを作成するかしたいです。これはフラスコで可能ですか?角度からの最良のアプローチは何ですか?