Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,23 @@
|
|
1 |
-
from flask import Flask, request, jsonify
|
2 |
-
|
3 |
-
import numpy as np
|
4 |
|
5 |
app = Flask(__name__)
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
[0, 0, 1, 1],
|
11 |
-
[1, 1, 0, 0],
|
12 |
-
[1, 0, 1, 0],
|
13 |
-
[0, 1, 0, 1]
|
14 |
-
]
|
15 |
|
16 |
-
|
17 |
-
|
|
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
response = [data['phishing'], data['ransomware'], data['ddos'], data['malware']]
|
27 |
-
prediction = model.predict([response])
|
28 |
-
return jsonify({'prediction': int(prediction[0])})
|
29 |
|
30 |
if __name__ == '__main__':
|
31 |
-
app.run(debug=True)
|
|
|
1 |
+
from flask import Flask, request, jsonify, send_from_directory
|
2 |
+
import os
|
|
|
3 |
|
4 |
app = Flask(__name__)
|
5 |
|
6 |
+
@app.route('/')
|
7 |
+
def index():
|
8 |
+
return send_from_directory('.', 'index.html')
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
@app.route('/<path:path>')
|
11 |
+
def static_files(path):
|
12 |
+
return send_from_directory('.', path)
|
13 |
|
14 |
+
@app.route('/log', methods=['POST'])
|
15 |
+
def log_action():
|
16 |
+
action_log = request.get_json()
|
17 |
+
log_file_path = os.path.join(app.root_path, 'user_actions.json')
|
18 |
+
with open(log_file_path, 'a') as f:
|
19 |
+
f.write(f"{action_log}\n")
|
20 |
+
return jsonify({"status": "success"}), 200
|
|
|
|
|
|
|
21 |
|
22 |
if __name__ == '__main__':
|
23 |
+
app.run(debug=True)
|