File tree Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ def index():
32
32
return render_template ('form.html' )
33
33
34
34
@app .route ('/predict' , methods = ['POST' ,'GET' ])
35
- def process ():
35
+ def predict ():
36
36
if request .method == 'POST' :
37
37
name = request .form ['name' ]
38
38
data = [name ]
@@ -44,15 +44,15 @@ def process():
44
44
return jsonify ({'error' :result })
45
45
return jsonify ({'name' :result })
46
46
elif request .method == 'GET' :
47
- name = request .args .get ('nameInput ' )
47
+ name = request .args .get ('commentInput ' )
48
48
data = [name ]
49
49
vect = cv .transform (data ).toarray ()
50
50
my_prediction = clf .predict (vect )
51
51
result = "Not a Spam"
52
52
if my_prediction == 'spam' :
53
53
result = "Spam"
54
- return jsonify ({'error ' :result })
55
- return jsonify ({'name ' :result })
54
+ return jsonify ({'outcome ' :result })
55
+ return jsonify ({'outcome ' :result })
56
56
57
57
58
58
# email = request.form['email']
Original file line number Diff line number Diff line change
1
+
1
2
$ ( document ) . ready ( function ( ) {
2
3
3
4
$ ( 'form' ) . on ( 'input' , function ( event ) {
4
-
5
+ // console.log($('#commentInput').val());
5
6
$ . ajax ( {
6
7
data : {
7
- name : $ ( '#nameInput' ) . val ( ) ,
8
- // email : $('#emailInput').val()
8
+ comment : $ ( 'commentInput' ) . val ( ) ,
9
+
10
+
9
11
} ,
10
12
type : 'POST' ,
11
13
url : '/predict'
14
+
12
15
} )
13
16
. done ( function ( data ) {
17
+ console . log ( data ) ;
14
18
15
19
if ( data . error ) {
16
20
$ ( '#errorAlert' ) . text ( data . error ) . show ( ) ;
@@ -22,6 +26,7 @@ $(document).ready(function() {
22
26
}
23
27
24
28
} ) ;
29
+
25
30
26
31
event . preventDefault ( ) ;
27
32
Original file line number Diff line number Diff line change 56
56
Spam Comment Detector
57
57
< form class ="form-inline ">
58
58
< div class ="form-group ">
59
- < input type ="text " class ="form-control " id ="nameInput " placeholder ="Type Here " style ="height:40px;font-size:20pt; " size ="40% ">
59
+ < input type ="text " class ="form-control " id ="nameInput " name =" commentInput " placeholder ="Type Here " style ="height:40px;font-size:20pt; " size ="40% ">
60
60
</ div >
61
61
</ form >
62
62
< div id ="successAlert " class ="alert alert-success " role ="alert " style ="display:none; width:50%; "> </ div >
You can’t perform that action at this time.
0 commit comments