Пример #1
0
def index():
    if request.method == "POST":
        try:
            if request.form:
                dict_req = dict(request.form)
                response = prediction.form_response(dict_req)
                return render_template("index.html", response=response)
            elif request.json:
                response = prediction.api_response(request.json)
                return jsonify(response)
        except Exception as e:
            #error = {"error":"Someting went wrong!! Try again"}
            error = {"error": e}
            return render_template("404.html", error=error)
    else:
        return render_template("index.html")
Пример #2
0
def index():
    if request.method == "POST":
        try:
            if request.form:
                data_req = dict(request.form)
                response = prediction.form_response(data_req)
                return render_template("index.html", response=response)
            elif request.json:
                response = prediction.api_response(request)
                return jsonify(response)
        except Exception as e:
            print(e)
            error = {"error": e}
            return render_template("404.html", error=error)
    else:
        return render_template("index.html")
Пример #3
0
def index():
    if request.method == 'POST':

        try:

            path = request.files['file']
            path = path.filename
            print(path)
            response = prediction.form_response(path)
            return render_template("index1.html", response=response)

        except Exception as e:
            error = {"error": e}
            return render_template("404.html", error=error)

    else:
        return render_template('index1.html')
Пример #4
0
def index():

    if request.method == "POST":
        try:
            if request.form:
                path = request.form['filename']
                response = prediction.form_response(path)
                return render_template("index.html", response=response)
            elif request.json:
                response = prediction.api_response(request.json)
                return jsonify(response)

        except Exception as e:
            print(e)
            error = {"error": e}

            return render_template("404.html", error=error)
    else:
        return render_template("index.html")
Пример #5
0
def index():
    if request.method == 'POST':
        try:
            if request.form:
                data_dir = dict(request.form)
                response = prediction.form_response(data_dir)
                return render_template("index.html", response=response)

            elif request.json:
                response = prediction.api_response(request.json)
                return jsonify(response)

        except Exception as e:
            print(e)
            # error = {"error":"Something went wrong !! Try Again"}
            error = {"error": e}
            return render_template("404.html", error=error)
    else:
        return render_template("index.html")
Пример #6
0
def index():

    if request.method == 'POST':

        try:
            if request.form:
                # data = [ i[1][0] for i in dict(request.form).items()]
                data_req = dict(request.form)
                # data = [list(map(float, data))]
                response = prediction.form_response(data_req)
                return render_template("index.html", response=response)
            elif request.json:
                response = prediction.api_response(request.json)
                return jsonify(response)

        except Exception as err:
            print(err)
            error = str(err)
            print(error)
            return render_template("404.html", error=err)
    else:
        return render_template('index.html')
Пример #7
0
def index():
    if request.method == 'POST':

        try:

            #print('file selected')
            #if 'file' in request.files :
            path = request.files['file']
            path = path.filename
            print(path)
            logger.log(file_object, "File name read successfully")
            response = prediction.form_response(path)
            return render_template("index1.html", response=response)
        #else:
        #print('File not found')

        except Exception as e:
            error = {"error": e}
            return render_template("404.html", error=error)

    else:
        return render_template('index1.html')
Пример #8
0
def index():
    if request.method == "POST":
        try:
            if request.form:
                # data = dict(request.form).values()
                # data = [list(map(float, data))]
                # response = predict(data)
                data_req = dict(request.form)
                response = prediction.form_response(data_req)
                return render_template("index.html", response=response)

            elif request.json:
                # response = api_response(request)
                response = prediction.api_response(request.json)
                return jsonify(response)

        except Exception as e:
            print(e)
            # error = {"error": "something went wrong!! Try again"}
            error = {"error": e}
            return render_template("404.html", error=e)
    else:
        return render_template("index.html")
Пример #9
0
def test_form_response_incorrect_range(data=input_data["incorrect_range"]):
    with pytest.raises(prediction_service.prediction.NotInRange):
        res = form_response(data)
Пример #10
0
def test_form_response_correct_range(data=input_data["correct_range"]):
    res = form_response(data)
    assert TARGET_range["min"] <= res <= TARGET_range["max"]
Пример #11
0
def test_form_response_correct_range(data=input_data['correct_range']):
    res = form_response(data)
    assert TARGET_range['min'] <= res <= TARGET_range['max']
Пример #12
0
def test_form_response_incorrect_range(data=input_data["incorrect_range"]):
    # whenever i am in "form_responses" and whenever i push the data in incorrect range
    # incorrect range for independent variables so at that time raise error (not in range)
    with pytest.raises(prediction_service.prediction.NotInRange):
        res = form_response(data)
Пример #13
0
def test_form_response_correct_range(data=input_data["correct_range"]):
    res = form_response(data)
    # assert means i have a condition and that must be true
    assert TARGET_range["min"] <= res <= TARGET_range["max"]
Пример #14
0
def test_form_response_incorrect_col(data=input_data["incorrect_col"]):
    with pytest.raises(prediction_service.prediction.NontInColumn):
        _ = form_response(data)