Skip to content

Commit 032c0c9

Browse files
committed
integrated api
1 parent 8426309 commit 032c0c9

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

app.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,29 @@
3131
def index():
3232
return render_template('form.html')
3333

34-
@app.route('/predict', methods=['POST'])
34+
@app.route('/predict', methods=['POST','GET'])
3535
def process():
36-
name = request.form['name']
37-
data = [name]
38-
vect = cv.transform(data).toarray()
39-
my_prediction = clf.predict(vect)
40-
result = "Not a Spam"
41-
if my_prediction == 'spam':
42-
result="Spam"
43-
return jsonify({'error':result})
44-
return jsonify({'name':result})
36+
if request.method == 'POST':
37+
name = request.form['name']
38+
data = [name]
39+
vect = cv.transform(data).toarray()
40+
my_prediction = clf.predict(vect)
41+
result = "Not a Spam"
42+
if my_prediction == 'spam':
43+
result="Spam"
44+
return jsonify({'error':result})
45+
return jsonify({'name':result})
46+
elif request.method=='GET':
47+
name = request.args.get('nameInput')
48+
data = [name]
49+
vect = cv.transform(data).toarray()
50+
my_prediction = clf.predict(vect)
51+
result = "Not a Spam"
52+
if my_prediction == 'spam':
53+
result="Spam"
54+
return jsonify({'error':result})
55+
return jsonify({'name':result})
56+
4557

4658
# email = request.form['email']
4759
# name = request.form['name']

0 commit comments

Comments
 (0)