-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
61 lines (43 loc) · 1.36 KB
/
server.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
import phishing_detection
from flask import Flask
from flask import (
Blueprint, flash, g, redirect, render_template, request, session, url_for
)
from flask import jsonify
from werkzeug.utils import secure_filename
app = Flask(__name__)
UPLOAD_FOLDER= '/files'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif','py'])
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@app.route('/result')
def result():
urlname = request.args['name']
result = phishing_detection.getResult(urlname)
return result
# @app.route('/upload')
# def upload():
# return 'yes'
@app.route('/', methods = ['GET', 'POST'])
def hello():
if request.method == 'POST':
if 'file' not in request.files:
flash('no file part')
return "false"
file = request.files['file']
if file.filename == '':
flash('no select file')
return 'false'
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
contents = file.read()
with open("files/URL.txt","wb") as f:
f.write(contents)
file.save = (os.path.join(app.config['UPLOAD_FOLDER'], filename))
return render_template("getInput.html")
return render_template("getInput.html")
if __name__ == '__main__':
app.run(debug=True)