-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.py
47 lines (38 loc) · 1.15 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
from flask import Flask, request, render_template, redirect
from database import Database
import subprocess
import json
import sqlite3
from security import safe_command
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/api')
def analyze():
host = request.args.get('host')
command = (['python', 'zap.py', '--url', host])
safe_command.run(subprocess.Popen, command)
response = {'status': 200}
return json.dumps(response) , 200, {'Content-Type': 'application/json; charset=utf-8'}
@app.route('/reports')
def reports():
report = request.args.get('report')
if report:
return render_template('reports/' + report)
else:
database = Database()
data = database.get_reports()
response = {
'status': 200,
'data': []
}
database.__exit__()
for da in data:
response['data'].append({
'app': da[0] + '.html',
'status': da[1]
})
response = json.dumps(response)
return response , 200, {'Content-Type': 'application/json; charset=utf-8'}
app.run()