mstkyvz commited on
Commit
6f3269f
1 Parent(s): 833c235

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -38
app.py CHANGED
@@ -1,38 +1,39 @@
1
- from flask import Flask, request, render_template
2
- import numpy as np
3
- import pickle
4
- import warnings
5
-
6
- warnings.filterwarnings('ignore')
7
- from feature import FeatureExtraction
8
-
9
-
10
- file = open("model.pkl", "rb")
11
- gbc = pickle.load(file)
12
-
13
- app = Flask(__name__)
14
-
15
- @app.route('/', methods=['GET', 'POST'])
16
- def index():
17
- result = None
18
- result_class = None
19
- url = None
20
- if request.method == 'POST':
21
- url = request.form['url']
22
- obj = FeatureExtraction(url)
23
- x = np.array(obj.getFeaturesList()).reshape(1, 30)
24
-
25
- y_pred = gbc.predict(x)[0]
26
- y_pro_phishing = gbc.predict_proba(x)[0, 0]
27
- y_pro_non_phishing = gbc.predict_proba(x)[0, 1]
28
-
29
- if y_pred == 1:
30
- result = "It is {0:.2f}% safe to go".format(y_pro_non_phishing * 100)
31
- result_class = "safe"
32
- else:
33
- result = "It is {0:.2f}% phishing".format(y_pro_phishing * 100)
34
- result_class = "phishing"
35
-
36
- return render_template('index.html', result=result, url=url, result_class=result_class)
37
- if __name__ == '__main__':
38
- app.run(debug=True)
 
 
1
+ from flask import Flask, request, render_template
2
+ import numpy as np
3
+ import pickle
4
+ import warnings
5
+
6
+ warnings.filterwarnings('ignore')
7
+ from feature import FeatureExtraction
8
+
9
+
10
+
11
+ with open("model.pkl", "rb") as file:
12
+ gbc = pickle.load(file)
13
+
14
+ app = Flask(__name__)
15
+
16
+ @app.route('/', methods=['GET', 'POST'])
17
+ def index():
18
+ result = None
19
+ result_class = None
20
+ url = None
21
+ if request.method == 'POST':
22
+ url = request.form['url']
23
+ obj = FeatureExtraction(url)
24
+ x = np.array(obj.getFeaturesList()).reshape(1, 30)
25
+
26
+ y_pred = gbc.predict(x)[0]
27
+ y_pro_phishing = gbc.predict_proba(x)[0, 0]
28
+ y_pro_non_phishing = gbc.predict_proba(x)[0, 1]
29
+
30
+ if y_pred == 1:
31
+ result = "It is {0:.2f}% safe to go".format(y_pro_non_phishing * 100)
32
+ result_class = "safe"
33
+ else:
34
+ result = "It is {0:.2f}% phishing".format(y_pro_phishing * 100)
35
+ result_class = "phishing"
36
+
37
+ return render_template('index.html', result=result, url=url, result_class=result_class)
38
+ if __name__ == '__main__':
39
+ app.run(debug=True)