コード例 #1
0
ファイル: movie.py プロジェクト: Diana3101/RESTfulAPI
def delete_movie():
    """
    Delete movie by id
    """
    data = get_request_data()
    if 'id' in data.keys():
        try:
            row_id = int(data['id'])
            Movie.delete(row_id)
        except:
            err = 'Id must be integer'
            return make_response(jsonify(error=err), 400)
    msg = 'Record successfully deleted'
    return make_response(jsonify(message=msg), 200)
コード例 #2
0
def delete_movie():
    """
    Delete movie by id
    """
    data = get_request_data()
    if 'id' in data.keys():
        try:
            row_id = int(data['id'])
        except:
            err = 'Id must be integer'
            return make_response(jsonify(error=err), 400)
        if Movie.delete(row_id):
            msg = 'Record successfully deleted'
            return make_response(jsonify(message=msg), 200)
        else:
            err = 'Record with such id does not exist'
            return make_response(jsonify(error=err), 400)
    else:
        err = 'No id specified'
        return make_response(jsonify(error=err), 400)