0

as shown below in the code,i have a webservice stashVector with POSTmethod. from angular i post the data shown in code section below. i would like to know how can i access the contents or the data posted to the webservice in python. for example, the object params contains the follwoing key-values:

let params = {
                "ID":this.ID,
                "threshold":this.threshold,
                "visOpD":this.visOpD
            }

how can i access the these keys and values from python code.

post in Angular

public startStashVector(params) {
  var endpointURL = this.buildEndpointURLForStashVectorForLocalHost();
  return this.httpClient.post(endpointURL,{
    method:'POST',
    body:JSON.stringify(params)
  })
    .subscribe((response)=>{
      console.log("WebServiceForStashVectorLocalHostResponse: ", response);
      this.eventEmitterResponseForStashVector.emit(response);
    });
}

webservice in python

@app.route("/stashVector/", methods=['POST','OPTIONS'])
def stashVector():

preFlight = FlaskAccessControlUtils.preFlightCheck(request)
if preFlight: return preFlight

print("selectedID: %s",request.args.get("body",""))
print("request.args: %s",request.form.getlist('name[]'))
exit()
LetsamrIt
  • 3,653
  • 7
  • 39
  • 72
  • You can get values by `params.ID`, `params.threshold`, `params.visOpD`. – N.F. Nov 24 '21 at 06:08
  • 1
    First of all why you are sending data in string, send data in JSON/Dictionary. After use requestBody = request.json and requestBody['threshold']. – Abhishek Nov 24 '21 at 06:16

0 Answers0