()
This router function saves the prediction results generated from a computed
    svm or svr prediction session.  During its attempt, it returns a json
    string, with the following value:

        - integer, codified indicator of save attempt:
            - 0, successfully stored the prediction result
            - 1, unsuccessfully stored the prediction result
            - 2, status was not 'valid'
            - 3, improper request submitted
def save_prediction():
    '''

    This router function saves the prediction results generated from a computed
    svm or svr prediction session.  During its attempt, it returns a json
    string, with the following value:

        - integer, codified indicator of save attempt:
            - 0, successfully stored the prediction result
            - 1, unsuccessfully stored the prediction result
            - 2, status was not 'valid'
            - 3, improper request submitted

    '''

    if request.method == 'POST':
        # web-interface: double decoder required, since nested encoding
        if request.form:
            results = request.form
            data = json.loads(json.loads(results['data']))

        # invalid request
        else:
            return json.dumps({'status': 3})

        # local variables
        status = results['status']
        type = results['model_type']
        title = results['title']

        # save prediction
        if status == 'valid':
            prediction = Prediction()
            result = prediction.save(data, type, title)['result']

            # notification: prediction status
            if result == 0:
                return json.dumps({'status': 0})
            else:
                return json.dumps({'status': 1})

        # notification: status not valid
        else:
            return json.dumps({'status': 2})
def save_prediction ( ) : if request . method == 'POST' : # web-interface: double decoder required, since nested encoding if request . form : results = request . form data = json . loads ( json . loads ( results [ 'data' ] ) ) # invalid request else : return json . dumps ( { 'status' : 3 } ) # local variables status = results [ 'status' ] type = results [ 'model_type' ] title = results [ 'title' ] # save prediction if status == 'valid' : prediction = Prediction ( ) result = prediction . save ( data , type , title ) [ 'result' ] # notification: prediction status if result == 0 : return json . dumps ( { 'status' : 0 } ) else : return json . dumps ( { 'status' : 1 } ) # notification: status not valid else : return json . dumps ( { 'status' : 2 } )