mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-28 17:49:01 +01:00
new search!
This commit is contained in:
parent
d3caf8bf93
commit
584ea806d3
1 changed files with 18 additions and 2 deletions
20
server.js
20
server.js
|
@ -98,8 +98,24 @@ app.get("/api/search", async (req, res) => {
|
||||||
if (!query) {
|
if (!query) {
|
||||||
return res.redirect("/");
|
return res.redirect("/");
|
||||||
}
|
}
|
||||||
fetcher.searcher(query,res)
|
return res.redirect(`/search?query=${query}`);
|
||||||
});
|
|
||||||
|
});
|
||||||
|
app.get("/search", async (req, res) => {
|
||||||
|
const { toJson } = require("xml2json");
|
||||||
|
const query = req.query.query;
|
||||||
|
const search = await fetch(
|
||||||
|
`https://lighttube.herokuapp.com/api/search?query=${query}`
|
||||||
|
);
|
||||||
|
const text = await search.text();
|
||||||
|
const j = JSON.parse(toJson(text));
|
||||||
|
if (!query) {
|
||||||
|
return res.redirect("/");
|
||||||
|
}
|
||||||
|
renderTemplate(res, req, "search.ejs", {
|
||||||
|
j: j,
|
||||||
|
});
|
||||||
|
});
|
||||||
app.get("/css/:id", (req, res) => {
|
app.get("/css/:id", (req, res) => {
|
||||||
res.sendFile(__dirname + `/css/${req.params.id}`);
|
res.sendFile(__dirname + `/css/${req.params.id}`);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue