forked from yashpatel301/Spam-Detector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
36 lines (26 loc) · 829 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
# -*- coding: utf-8 -*-
"""Spam_Project_app.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1uZ6UugZukCxA1W4opoa3rlSEH5XxdkX6
"""
from flask import Flask
from flask import render_template, url_for, request
import pickle
app = Flask(__name__)
filename = 'spam_model.pkl'
clf = pickle.load(open(filename, 'rb'))
cv = pickle.load(open('transform.pkl', 'rb'))
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict', methods=['POST'])
def predict():
if request.method=='POST':
msg = request.form['msg']
data = [msg]
vector = cv.transform(data).toarray()
predicting = clf.predict(vector)
return render_template('result.html',prediction=predicting)
if __name__ =='__main__':
app.run(debug = True)