def hello():
    message = request.get_json(force=True)
    age = message['age']
    gender = message['gender']
    smoking = message['smoking']
    HTN = message['HTN']
    DPL = message['DPL']
    DM = message['DM']
    physical_exercise = message['physical_exercise']
    family_history = message['family_history']
    drug_history = message['drug_history']
    psychological_stress = message['psychological_stress']
    chest_pain = message['chest_pain']
    dyspnea = message['dyspnea']
    palpitation = message['palpitation']
    ECG = message['ECG']
    """for key in message:
					print(message[key])
				
				asd = message.values
				asd = np.array(asd)
				for i in len(asd):
					print(asd[i])"""

    #print(type(asd))

    #x = []

    #for key in message.keys():
    #	x.append(message[key])

    #print(x)

    data = user_data_process(message)
    print(data)

    x = []

    for key in data.keys():
        x.append(data[key])

    print(x)

    #predicted_value = []

    #predicted_value = NN(x)
    predicted_value = NN2(x)
    #predicted_value = NN1(x,model1)

    respone = {
        "gretting":
        "hello, " + age + ". your gender is : " + gender +
        ". your smoking habit: " + smoking + ". HTN: " + HTN + ". DPL: " +
        DPL + ". DM: " + DM + ". physical_exercise: " + physical_exercise,
        "prediction":
        str(predicted_value)
    }

    return jsonify(respone)
def predict():
    #get jeson values
    message = request.get_json(force=True)
    age = message['age']
    gender = message['gender']
    smoking = message['smoking']
    HTN = message['HTN']
    DPL = message['DPL']
    DM = message['DM']
    physical_exercise = message['physical_exercise']
    family_history = message['family_history']
    drug_history = message['drug_history']
    psychological_stress = message['psychological_stress']
    chest_pain = message['chest_pain']
    dyspnea = message['dyspnea']
    palpitation = message['palpitation']
    ECG = message['ECG']
    #process data
    data = user_data_process(message)

    x = []

    for key in data.keys():
        x.append(data[key])

    predicted_value, probability = NN2(x)
    print(probability)
    # Database insert new data
    cur = mysql.connection.cursor()
    cur.execute(
        "INSERT INTO dataset(age,gender,smoking,HTN,DPL,DM,physical_exercise,family_history,drug_history,psychological_stress,chest_pain,dyspnea,palpitation,ECG,IHD,probability) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
        (age, gender, smoking, HTN, DPL, DM, physical_exercise, family_history,
         drug_history, psychological_stress, chest_pain, dyspnea, palpitation,
         ECG, predicted_value, probability))
    mysql.connection.commit()
    cur.close()

    result = ''
    if (predicted_value == 1):
        result = 'According to the information our prediction result is YES'
    else:
        result = 'According to the information our prediction result is no'

    respone = {
        "gretting":
        "hello,  Lets take a look at the information that you provide. your age is: "
        + age + ". your gender is : " + gender + ". your smoking habit: " +
        smoking + ". HTN: " + HTN + ". DPL: " + DPL + ". DM: " + DM +
        ". physical_exercise: " + physical_exercise +
        ". your family_history: " + family_history + ". drug_history: " +
        drug_history + ". psychological_stress: " + psychological_stress +
        ". chest_pain: " + chest_pain + ". dyspnea: " + dyspnea +
        ". palpitation: " + palpitation + ". ECG Report: " + ECG + ". ",
        "prediction":
        result
    }

    return jsonify(respone)