Spaces:
Running
Running
add support for multiple domains
Browse files- app/static/index.html +4 -4
- app/static/script.js +14 -3
- app/static/style.css +35 -19
app/static/index.html
CHANGED
@@ -21,12 +21,12 @@
|
|
21 |
</a>
|
22 |
</p>
|
23 |
<form class="text-gen-form">
|
24 |
-
<label for="text-gen-input">
|
25 |
-
|
26 |
id="text-gen-input"
|
27 |
type="text"
|
28 |
-
|
29 |
-
|
30 |
<button id="text-gen-submit">Submit</button>
|
31 |
<p class="text-gen-output"></p>
|
32 |
</form>
|
|
|
21 |
</a>
|
22 |
</p>
|
23 |
<form class="text-gen-form">
|
24 |
+
<label for="text-gen-input">A list of domain names </label>
|
25 |
+
<textarea
|
26 |
id="text-gen-input"
|
27 |
type="text"
|
28 |
+
value="www.google.com">
|
29 |
+
</textarea>
|
30 |
<button id="text-gen-submit">Submit</button>
|
31 |
<p class="text-gen-output"></p>
|
32 |
</form>
|
app/static/script.js
CHANGED
@@ -5,16 +5,27 @@ const translateText = async (text) => {
|
|
5 |
const inferJson = await inferResponse.json();
|
6 |
console.log(inferResponse);
|
7 |
console.log(inferJson);
|
8 |
-
const res
|
9 |
return res
|
10 |
-
|
11 |
};
|
12 |
|
|
|
13 |
textGenForm.addEventListener("submit", async (event) => {
|
14 |
event.preventDefault();
|
15 |
|
16 |
const textGenInput = document.getElementById("text-gen-input");
|
17 |
const textGenParagraph = document.querySelector(".text-gen-output");
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
});
|
|
|
|
5 |
const inferJson = await inferResponse.json();
|
6 |
console.log(inferResponse);
|
7 |
console.log(inferJson);
|
8 |
+
const res = `domain:"${text}",probDGA:${inferJson.probability}`;
|
9 |
return res
|
|
|
10 |
};
|
11 |
|
12 |
+
|
13 |
textGenForm.addEventListener("submit", async (event) => {
|
14 |
event.preventDefault();
|
15 |
|
16 |
const textGenInput = document.getElementById("text-gen-input");
|
17 |
const textGenParagraph = document.querySelector(".text-gen-output");
|
18 |
|
19 |
+
// Split the inputted text into separate domains
|
20 |
+
const domains = textGenInput.value.trim().split('\n');
|
21 |
+
|
22 |
+
let output = '';
|
23 |
+
|
24 |
+
// Loop over each domain and submit it to the URL one at a time
|
25 |
+
for (let i = 0; i < domains.length; i++) {
|
26 |
+
output += await translateText(domains[i]) + '\n';
|
27 |
+
}
|
28 |
+
|
29 |
+
textGenParagraph.textContent = output;
|
30 |
});
|
31 |
+
|
app/static/style.css
CHANGED
@@ -1,20 +1,3 @@
|
|
1 |
-
body {
|
2 |
-
--text: hsl(0 0% 15%);
|
3 |
-
padding: 2.5rem;
|
4 |
-
font-family: sans-serif;
|
5 |
-
color: var(--text);
|
6 |
-
}
|
7 |
-
|
8 |
-
body.dark-theme {
|
9 |
-
--text: hsl(0 0% 90%);
|
10 |
-
background-color: hsl(223 39% 7%);
|
11 |
-
}
|
12 |
-
|
13 |
-
main {
|
14 |
-
max-width: 80rem;
|
15 |
-
text-align: center;
|
16 |
-
}
|
17 |
-
|
18 |
section {
|
19 |
display: flex;
|
20 |
flex-direction: column;
|
@@ -30,16 +13,49 @@ form {
|
|
30 |
margin: 0 auto;
|
31 |
}
|
32 |
|
33 |
-
input
|
|
|
34 |
width: 100%;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
|
37 |
button {
|
38 |
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
|
41 |
.text-gen-output {
|
42 |
min-height: 1.2rem;
|
43 |
margin: 1rem;
|
44 |
-
|
|
|
|
|
45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
section {
|
2 |
display: flex;
|
3 |
flex-direction: column;
|
|
|
13 |
margin: 0 auto;
|
14 |
}
|
15 |
|
16 |
+
input,
|
17 |
+
textarea {
|
18 |
width: 100%;
|
19 |
+
height: 8rem;
|
20 |
+
margin-top: 0.5rem;
|
21 |
+
padding: 0.5rem;
|
22 |
+
font-size: 1rem;
|
23 |
+
border: 1px solid #ccc;
|
24 |
+
border-radius: 5px;
|
25 |
+
resize: vertical;
|
26 |
+
text-align: left;
|
27 |
+
}
|
28 |
+
|
29 |
+
label {
|
30 |
+
font-size: 1.2rem;
|
31 |
+
color: #777;
|
32 |
+
margin-top: 1rem;
|
33 |
}
|
34 |
|
35 |
button {
|
36 |
cursor: pointer;
|
37 |
+
background-color: #4CAF50;
|
38 |
+
color: white;
|
39 |
+
padding: 0.5rem 1rem;
|
40 |
+
border: none;
|
41 |
+
border-radius: 5px;
|
42 |
+
font-size: 1rem;
|
43 |
+
margin-top: 1rem;
|
44 |
+
}
|
45 |
+
|
46 |
+
h1 {
|
47 |
+
font-size: 2.5rem;
|
48 |
+
margin: 2rem 0;
|
49 |
+
text-align: center;
|
50 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
51 |
+
color: #333;
|
52 |
}
|
53 |
|
54 |
.text-gen-output {
|
55 |
min-height: 1.2rem;
|
56 |
margin: 1rem;
|
57 |
+
padding: 0.5rem;
|
58 |
+
border: 1px solid grey;
|
59 |
+
border-radius: 5px;
|
60 |
}
|
61 |
+
|