-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
32 lines (23 loc) · 748 Bytes
/
server.py
File metadata and controls
32 lines (23 loc) · 748 Bytes
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
from flask import Flask, render_template, request
import pickle
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html')
@app.route('/detect', methods=['POST'])
def detect():
if request.method == 'POST':
inp = request.form['text_input']
with open('vectorizer.pickle', 'rb') as f:
cv = pickle.load(f)
res = cv.transform([inp]).toarray()
with open('spam.pickle', 'rb') as f:
clf = pickle.load(f)
op = clf.predict(res)
if op[0] == 'ham':
label = 'not spam'
else:
label = 'spam'
return render_template('index.html', op=label)
if __name__ == '__main__':
app.run(debug=False, host='0.0.0.0')