jeudi 22 novembre 2018

How to do a if statement in a method that test the value contained in a JSON

I'm new to Python and I'm doing a server with a method called sendCmd. When the user select an option on the webpage it does a POST with the value selected. I'm doing a if statement to adapt the behaviour and I have the error 500. So now I'm trying to do a really basic if but I still have the error 500. I don't know how to get the stack trace to see more advanced errors message.

My goal at the end is to test something like

if data contains X do that, else if it contains Y do that ....

@app.route('/data', methods=['POST'])
    def sendCmd():
        data = request.get_json(force=True)
        var1 = 100
        if var1:
           print "1 - Got a true expression value"
           print var1
        else:
           print "1 - Got a false expression value"
           print var1
        return jsonify(data)




Aucun commentaire:

Enregistrer un commentaire