-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdetect.py
40 lines (32 loc) · 1.13 KB
/
detect.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
36
37
38
39
40
import joblib
from flask import Flask, render_template, request
import features_new
app = Flask(__name__)
phish_model = open('new_model.pkl', 'rb')
clf = joblib.load(phish_model)
@app.route('/')
def index():
return render_template("index.html")
@app.route('/getURL',methods=['GET','POST'])
def getURL():
if request.method == 'POST':
url = request.form['url']
print(url)
data = features_new.main(url)
print(data)
if data == "Invalid URL":
value = "Invalid"
return render_template("index.html", error=value)
else:
predicted_value = clf.predict(data)
if int(predicted_value[0]) == 1:
value = "Phishing"
return render_template("index.html", error=value)
elif int(predicted_value[0]) == -1:
value = "Legitimate"
return render_template("index.html", error=value)
else:
value = "Invalid Input"
return render_template("index.html", error=value)
if __name__ == "__main__":
app.run(debug=True)