-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
40 lines (29 loc) · 983 Bytes
/
app.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
32
33
34
35
36
37
38
39
40
from flask import Flask, render_template,request
import pickle
app = Flask(__name__)
data_email = ""
msg = ""
#loading models
filename = 'NaiveModel.pkl'
classifier = pickle.load(open(filename, 'rb'))
cv = pickle.load(open('cv-transform.pkl','rb'))
@app.route("/")
def index():
return render_template("index.html")
@app.route("/check", methods=["POST"])
def check():
if request.method == "POST":
#Request data
data_email = request.form["email_text"]
data = [data_email]
#models
vect = cv.transform(data).toarray()
class_type = classifier.predict(vect)
#return msg
if class_type == ['spam'] :
msg = """<h4 style="color: red">Spam email be aware !!!!</h4>"""
else :
msg = """<h4 style="color: green">email looks Good<<->> </h4>"""
return render_template("index.html" ,msg= msg, data_email = data_email )
if __name__ == "__main__":
app.run()