flask 参数校验

校验参数是否存在,不存在返回400

 

@app.route('/check',methods=['POST'])
def check():
    values = request.get_json()
    required = ['a','b','c']
    if not all(k in values for k in required):
        return "Missing values",400

  

posted @ 2019-12-31 15:38  sunshine_5  阅读(2012)  评论(0编辑  收藏  举报