-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
83 lines (63 loc) · 2.3 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/python
# __author__ = 'jasonsheh'
# -*- coding:utf-8 -*-
from flask import Flask, render_template, request, redirect, flash
import sys
from fingerprint import FingerPrint
from database import Rules
app = Flask(__name__)
app.secret_key = "super secret key"
@app.route('/')
@app.route('/index')
def index():
total_number = Rules().count()
return render_template('index.html', total_number=total_number)
@app.route('/browser')
def browser():
return render_template('browser.html')
@app.route('/login', methods=['POST'])
def login():
if request.method == 'POST':
if request.form.get('username') and request.form.get('password'):
username = request.form.get('username')
password = request.form.get('password')
if username == 'admin' and password == 'password':
return render_template('manage.html')
return redirect('/index')
@app.route('/fingerprint', methods=['POST'])
def add_task():
if request.method == 'POST':
if request.form.get('finger').find('.') != -1:
result = FingerPrint(request.form.get('finger'), request.form.get('protocol')).run()
flash(result.split(' ')[:-1])
return redirect('/index')
@app.route('/add', methods=['POST'])
def add_rule():
if request.method == 'POST':
if request.form.get('name') and request.form.get('rule'):
name = request.form.get('name')
rule = request.form.get('rule')
Rules().add_rule(name, rule)
return render_template('manage.html')
@app.route('/delete', methods=['POST'])
def delete_rule():
if request.method == 'POST':
if request.form.get('name'):
name = request.form.get('name')
Rules().delete_rule(name=name)
if request.form.get('id'):
id = request.form.get('id')
Rules().delete_rule(id=id)
return render_template('manage.html')
@app.route('/search', methods=['POST'])
def search_rule():
if request.method == 'POST':
if request.form.get('name'):
name = request.form.get('name')
results = Rules().search_rule(name)
return render_template('manage.html', results=results)
if __name__ == '__main__':
try:
app.run()
except KeyboardInterrupt:
sys.exit()