I am deploying my flask python app on heroku but I am getting an application error.
This is my app.py file:
# Importing essential libraries
from flask import Flask, render_template, request
import pickle
# Load the Multinomial Naive Bayes model and CountVectorizer object from disk
filename = 'movie-genre-mnb-model.pkl'
classifier = pickle.load(open(filename, 'rb'))
cv = pickle.load(open('cv-transform.pkl','rb'))
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict',methods=['POST'])
def predict():
if request.method == 'POST':
message = request.form['message']
data = [message]
vect = cv.transform(data).toarray()
my_prediction = classifier.predict(vect)
return render_template('after.html', prediction=my_prediction)
if __name__ == '__main__':
#app.run(host="localhost", port=3000, debug=True)
#log.Fatal(http.ListenAndServe(":" + os.Getenv("PORT"), router))
app.run(debug=True)
This is Procfile:
web: gunicorn app:app
When I run heroku logs --tail
command I get this:
2021-01-09T07:57:17.773012+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=movie-pred-ml.herokuapp.com request_id=df65bbf3-c19c-4410-9efd-ecd3a1748189 fwd="152.57.42.38" dyno= connect= service= status=503 bytes= protocol=https
2021-01-09T07:57:18.216690+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=movie-pred-ml.herokuapp.com request_id=5ef8bf3c-5e50-4304-b0c4-33ffa670443f fwd="152.57.42.38" dyno= connect= service= status=503 bytes= protocol=https
How should I solve this error?