我已部署的flask应用程序中的错误,显示500个内部服务器错误

时间:2020-06-26 12:12:54

标签: python flask

我制作了可以诊断疾病的python烧瓶应用程序 该应用程序在本地运行良好,但是通过Heroku进行部署时,我得到了500个内部错误,我知道该错误意味着什么,但是我找不到我的应用程序中的错误,因此,我相信只要关注StackOverflow即可

从sklearn导入svm 从sklearn导入预处理 从sklearn.model_selection导入train_test_split 从烧瓶进口烧瓶 进口泡菜 将numpy导入为np 将熊猫作为pd导入 导入操作系统

app = Flask(__name__)


@app.route('/hello')
def home():
    return 'hello'


@app.route('/rf/<sym1>/<sym2>/<sym3>/<sym4>/<sym5>')
def predict(sym1, sym2, sym3, sym4, sym5):




    l1=['back pain','constipation','abdominal pain','diarrhoea','mild fever','yellow urine',
    'yellowing of eyes','acute liver failure','fluid overload','swelling of stomach',
    'swelled lymph nodes','malaise','blurred and distorted vision','phlegm','throat irritation',
    'redness of eyes','sinus pressure','runny nose','congestion','chest pain','weakness in limbs',
    'fast heart rate','pain during bowel movements','pain in anal region','bloody stool',
    'irritation in anus','neck pain','dizziness','cramps','bruising','obesity','swollen legs',
    'swollen blood vessels','puffy face and eyes','enlarged thyroid','brittle nails',
    'swollen extremeties','excessive hunger','extra marital contacts','drying and tingling lips',
    'slurred speech','knee pain','hip joint pain','muscle weakness','stiff neck','swelling joints',
    'movement stiffness','spinning movements','loss of balance','unsteadiness',
    'weakness of one body side','loss of smell','bladder discomfort','foul smell of urine',
    'continuous feel of urine','passage of gases','internal itching','toxic look (typhos)',
    'depression','irritability','muscle pain','altered sensorium','red spots over body','belly pain',
    'abnormal menstruation','dischromic  patches','watering from eyes','increased 
appetite','polyuria','family history','mucoid sputum',
    'rusty sputum','lack of concentration','visual disturbances','receiving blood transfusion',
    'receiving unsterile injections','coma','stomach bleeding','distention of abdomen',
    'history of alcohol consumption','fluid overload','blood in sputum','prominent veins on calf',
    'palpitations','painful walking','pus filled pimples','blackheads','scurring','skin peeling',
    'silver like dusting','small dents in nails','inflammatory nails','blister','red sore around nose',
    'yellow crust ooze']

     disease=['Fungal infection','Allergy','GERD','Chronic cholestasis','Drug Reaction',
    'Peptic ulcer diseae','AIDS','Diabetes','Gastroenteritis','Bronchial Asthma','Hypertension',
    'Migraine','Cervical spondylosis',
    'Paralysis (brain hemorrhage)','Jaundice','Malaria','Chicken pox','Dengue','Typhoid','hepatitis A',
    'Hepatitis B','Hepatitis C','Hepatitis D','Hepatitis E','Alcoholic hepatitis','Tuberculosis',
    'Common Cold','Pneumonia','Dimorphic hemmorhoids(piles)',
    'Heartattack','Varicoseveins','Hypothyroidism','Hyperthyroidism','Hypoglycemia','Osteoarthristis',
    'Arthritis','(vertigo) Paroymsal  Positional Vertigo','Acne','Urinary tract infection','Psoriasis',
    'Impetigo']

    l2=[]
    for x in range(0,len(l1)):
        l2.append(0)


    from sklearn.ensemble import RandomForestClassifier
    clf3 = RandomForestClassifier()
    clf3 = clf3.fit(X,np.ravel(y))
    #filename = 'model.sav'
    #pickle.dump(clf3, open(filename, 'wb'))
    model = 
    pickle.load(open(os.path.abspath(os.path.dirname(__file__).replace("",""))+"/asset/model.sav", "rb"))
    print("model loaded")

# calculating accuracy-------------------------------------------------------------------
#from sklearn.metrics import accuracy_score
#y_pred=clf3.predict(X_test)
#print(accuracy_score(y_test, y_pred))
#print(accuracy_score(y_test, y_pred,normalize=False))
# -----------------------------------------------------
    Symptom1 = '%s' % sym1

    Symptom2 = '%s' % sym2

    Symptom3 = '%s' % sym3

    Symptom4 = '%s' % sym4

    Symptom5 = '%s' % sym5


    psymptoms = [Symptom1,Symptom2,Symptom3,Symptom4,Symptom5]

    for k in range(0,len(l1)):
    # print (k,)
        for z in psymptoms:
            if(z==l1[k]):
                l2[k]=1

    inputtest = [l2]
    predict = model.predict(inputtest)
    predicted=predict[0]
    #print(predicted)
    #assigning a string value to "a"
    for a in range(0,len(disease)):
        if(predicted == a):
            break
   
    return disease[a]#returning the disease

if __name__ == '__main__':
app.run(debug=True)

如果您遇到一些缩进错误,那不是问题,因为在我将其复制粘贴到网站上时可能缩进了错误

另外,指向“ / hello”的网址也可以正常工作,这表明我的预测函数有错误

请回答

关于, 肉山

0 个答案:

没有答案