sahar-yaccov commited on
Commit
eebc277
ยท
verified ยท
1 Parent(s): e25856f

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +49 -14
templates/index.html CHANGED
@@ -13,31 +13,66 @@
13
  <h1>๐Ÿ›ก๏ธ Microsoft Security Attack Classifier</h1>
14
  <p>Select values and see if the model detects an attack based on the security update.</p>
15
 
16
- <form method="POST"> <!-- ื˜ื•ืคืก ืฉื™ืฉืœื— ื‘ืงืฉืช POST ืœืฉืจืช -->
17
- {% for feature in features %} <!-- ืœื•ืœืื” ืฉืขื•ื‘ืจืช ืขืœ ื›ืœ ืฉื ืคื™ืฆ'ืจ -->
18
- <label for="{{ feature }}">{{ feature }}</label><br> <!-- ืชื•ื•ื™ืช ืœืคื™ืฆ'ืจ ืขื ืฉื ื“ื™ื ืžื™ -->
19
- <select name="{{ feature }}" required> <!-- ืชื™ื‘ืช ื‘ื—ื™ืจื” ืขื ืฉื ืฉื•ื•ื” ืœืคื™ืฆ'ืจ, ื—ื•ื‘ื” ืœืžืœื -->
20
- {% for option in options_dict[feature] %} <!-- ืœื•ืœืื” ืขืœ ื›ืœ ื”ืืคืฉืจื•ื™ื•ืช ืœืคื™ืฆ'ืจ ื–ื” -->
21
- <option value="{{ option }}">{{ option }}</option> <!-- ืื•ืคืฆื™ื” ืœื‘ื—ื™ืจื”, ื’ื ืขืจืš ื’ื ืชืฆื•ื’ื” ื–ื”ื” -->
22
  {% endfor %}
23
- </select><br><br> <!-- ืฉื•ืจื” ืจื™ืงื” ื‘ื™ืŸ ื”ื‘ื—ื™ืจื•ืช -->
24
  {% endfor %}
25
 
26
- <button type="submit">๐Ÿ” Predict </button> <!-- ื›ืคืชื•ืจ ืœืฉืœื™ื—ืช ื”ื˜ื•ืคืก -->
27
  </form>
28
 
29
-
30
- {% if prediction %} <!-- ืื ื”ืžืฉืชื ื” prediction ืงื™ื™ื ื•ืžื›ื™ืœ ืขืจืš -->
31
- <div class="result"> <!-- ืชื™ื‘ื” ืœืขื™ืฆื•ื‘ ื”ืชื•ืฆืื” -->
32
- <h2>{{ prediction }}</h2> <!-- ื”ืฆื’ืช ื˜ืงืกื˜ ื”ืชื—ื–ื™ืช ืฉื”ืฉืจืช ื”ื—ื–ื™ืจ -->
33
  </div>
34
  {% endif %}
35
 
36
-
37
  <footer>
38
  โšก Built by <a href="https://github.com/ss331144" target="_blank">Sahar Yaccov</a> and <a href="https://github.com/BarCohen-dot" target="_blank">Bar Cohen</a>
39
  </footer>
40
-
41
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  </body>
43
  </html>
 
13
  <h1>๐Ÿ›ก๏ธ Microsoft Security Attack Classifier</h1>
14
  <p>Select values and see if the model detects an attack based on the security update.</p>
15
 
16
+ <form id="predictForm" method="POST">
17
+ {% for feature in features %}
18
+ <label for="{{ feature }}">{{ feature }}</label><br>
19
+ <select name="{{ feature }}" required>
20
+ {% for option in options_dict[feature] %}
21
+ <option value="{{ option }}">{{ option }}</option>
22
  {% endfor %}
23
+ </select><br><br>
24
  {% endfor %}
25
 
26
+ <button type="submit">๐Ÿ” Predict </button>
27
  </form>
28
 
29
+ {% if prediction %}
30
+ <div class="result">
31
+ <h2>{{ prediction }}</h2>
32
+ <button id="downloadBtn">โฌ‡๏ธ Download Prediction</button>
33
  </div>
34
  {% endif %}
35
 
 
36
  <footer>
37
  โšก Built by <a href="https://github.com/ss331144" target="_blank">Sahar Yaccov</a> and <a href="https://github.com/BarCohen-dot" target="_blank">Bar Cohen</a>
38
  </footer>
 
39
  </div>
40
+
41
+ <script>
42
+ {% if prediction %}
43
+ document.getElementById('downloadBtn').addEventListener('click', function() {
44
+ // ืืกื•ืฃ ืืช ื”ืขืจื›ื™ื ืžื”ื˜ื•ืคืก
45
+ const form = document.getElementById('predictForm');
46
+ const formData = new FormData(form);
47
+ let content = '';
48
+
49
+ // ื”ื•ืกืฃ ืชืืจื™ืš ื•ืฉืขื”
50
+ const now = new Date();
51
+ content += `Date: ${now.toISOString().slice(0,10)}\n`;
52
+ content += `Time: ${now.toTimeString().slice(0,8)}\n\n`;
53
+
54
+ // ื”ื•ืกืฃ ื›ืœ ืฉื“ื” ืžื”ื˜ื•ืคืก
55
+ for (let [key, value] of formData.entries()) {
56
+ content += `${key}: ${value}\n`;
57
+ }
58
+
59
+ // ื”ื•ืกืฃ ืืช ื”ื—ื™ื–ื•ื™
60
+ content += `\nPrediction: {{ prediction | e }}\n`;
61
+
62
+ // ืฆื•ืจ ื‘ืœื•ื‘ ื˜ืงืกื˜
63
+ const blob = new Blob([content], { type: 'text/plain' });
64
+ const url = URL.createObjectURL(blob);
65
+
66
+ // ืฆื•ืจ ืงื™ืฉื•ืจ ืœื”ื•ืจื“ื” ื•"ืงืœื™ืง" ืขืœื™ื•
67
+ const a = document.createElement('a');
68
+ a.href = url;
69
+ a.download = 'prediction.txt';
70
+ a.click();
71
+
72
+ // ืฉื—ืจืจ ืืช ื”ืื•ื‘ื™ื™ืงื˜
73
+ URL.revokeObjectURL(url);
74
+ });
75
+ {% endif %}
76
+ </script>
77
  </body>
78
  </html>