lundi 6 mars 2017

Heroku Flask App Internal Server Error

Hi I'm just starting with Heroku and my expected outcome is to deploy a Flask web app that runs on my machine learning model.

I want the app to process in the following manner:

1) The app starts and displays "first_app.html" where I have the fields to input data. 2) The input is then processed in "WebApp.py" app file. 3) The result is then displayed at "result.html".

from flask import Flask, render_template, request
from sklearn.externals import joblib
import sklearn
import os
import pickle

# os.chdir("C:\\Users\\vivek\\PycharmProjects\\WebApp")

app = Flask(__name__)

@app.route('/', methods=['GET','POST'])
def send():
    if request.method == 'POST':
        crim = request.form['crim']
        zn = request.form['zn']
        indus = request.form['indus']
        chas = request.form['chas']
        nox = request.form['nox']
        rm = request.form['rm']
        age = request.form['age']
        dis = request.form['dis']
        rad = request.form['rad']
        tax = request.form['tax']
        ptratio = request.form['ptratio']
        bk = request.form['bk']
        lstat = request.form['lstat']
        params =[crim,zn,indus,chas,nox,rm,age,dis,rad,tax,ptratio,bk,lstat]
        file = "houseprice.pkl"
        model = joblib.load(file)

        mvalue = model.predict(params)
        med_value = mvalue[0]
        med_value = med_value * 10000
        return render_template('result.html',med_value=med_value)
    return render_template('first_app.html')

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

When I deploy this code in Heroku, the "first_app.html" page opens but when I submit my inputs, it shows the following error:

500 Internal Server Error:

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

I'm just a beginner trying to get a hang of Flask and developing machine learning products, so I could debug the issue well.




Aucun commentaire:

Enregistrer un commentaire