-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
47 lines (39 loc) · 1.61 KB
/
app.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
import flask
from flask import Flask, render_template, request, redirect
from eval import main
app = Flask(__name__)
#Basic Web Pages
#-------------------------------------------------------------------------------------------
@app.route("/")
@app.route("/index")
def index():
return render_template("index.html")
@app.route("/features")
def features():
return render_template("features.html")
@app.route("/analysis")
def analysis():
return render_template("analysis.html")
@app.route("/model")
def model():
return render_template("model.html")
#-------------------------------------------------------------------------------------------
@app.route("/submit", methods=['POST'])
def submit():
if request.method=="POST":
type = request.form.get("traffic_type")
expected = type
type = type.lower()
print(type)
attacks = ["normal","dos","r2l","u2r","probe"]
if type not in attacks:
return render_template("index.html")
pred, prob, predsvm, probsvm = main(type)
dict = {"expected":expected,"predictions":attacks[pred], "normal":prob[0], "dos":prob[1], "u2r":prob[3], "r2l":prob[2], "probe":prob[4]}
dictsvm = {"expected":expected,"predictionssvm":attacks[predsvm], "normal":probsvm[0], "dos":probsvm[1], "u2r":probsvm[3], "r2l":probsvm[2], "probe":probsvm[4]}
return render_template("result.html",dict=dict,dictsvm=dictsvm)
# Commands to run
#-------------------------------------------------------------------------------------------
# export FLASK_APP=server.py
# export FLASK_DEBUG=1
# python -m flask run --host 0.0.0.0 --port 5000