Testing some stuff

This commit is contained in:
Danny Spina 2023-06-19 12:20:11 +02:00
parent 869585ae29
commit 6507a5667d
2 changed files with 15 additions and 1 deletions

9
dist/index.html vendored
View File

@ -48,10 +48,17 @@
timeout errors from occurring. timeout errors from occurring.
</p> </p>
<script> <script>
const DEV_MODE = false
let url = "https://ill-red-skunk-wig.cyclic.app"
if (DEV_MODE) {
url = "http://localhost:8888"
}
const b = document.querySelector("button"), const b = document.querySelector("button"),
i = document.querySelector("input"); i = document.querySelector("input");
b.addEventListener("click", () => { b.addEventListener("click", () => {
location.href = `https://ill-red-skunk-wig.cyclic.app?q=${encodeURI(i.value)}`; location.href = `${url}?q=${encodeURI(i.value)}`;
}); });
</script> </script>
</body> </body>

View File

@ -24,6 +24,13 @@ app.get("/", (req, res) => {
got(`${searchEngine}?q=${query}`) got(`${searchEngine}?q=${query}`)
.then((response) => { .then((response) => {
if (response.statusCode !== 200) {
console.log("Error code:", response.statusCode)
res.send(`Error code ${response.statusCode}`)
return;
}
const dom = new JSDOM(response.body); const dom = new JSDOM(response.body);
const links = dom.window.document.querySelectorAll('link') const links = dom.window.document.querySelectorAll('link')
const results = dom.window.document.querySelectorAll('.result') const results = dom.window.document.querySelectorAll('.result')