-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathFlaskApp.py
31 lines (25 loc) · 818 Bytes
/
FlaskApp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: utf-8 -*-
from flask import Flask,render_template,url_for,request
import pickle
import preprocessing
# load the model from disk
clf = pickle.load(open('nb_clf.pkl', 'rb'))
cv=pickle.load(open('tfidf_model.pkl','rb'))
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html')
@app.route('/predict',methods=['POST'])
def predict():
if request.method == 'POST':
message = request.form['message']
if(len(message)>2):
text = [message]
data = preprocessing.text_Preprocessing(text)
vect = cv.transform(data)
my_prediction = clf.predict(vect)
else:
my_prediction=3
return render_template('home.html',prediction = my_prediction)
if __name__ == '__main__':
app.run(debug=True)