1
0
Fork 0
mirror of https://codeberg.org/ashley/poke.git synced 2024-11-17 00:34:41 -05:00

add web search~ :3

This commit is contained in:
Ashley 2023-10-17 18:24:10 +00:00
parent 7c90af5004
commit c85b0d0b06

View file

@ -63,7 +63,11 @@ module.exports = function (app, config, renderTemplate) {
app.get("/search", async (req, res) => {
const query = req.query.query;
const tab = req.query.tab
const search = require('google-it')
var uaos = req.useragent.os;
var IsOldWindows;
@ -112,15 +116,22 @@ module.exports = function (app, config, renderTemplate) {
let didYouMean;
if ( searchJson.Search?.Results?.DynamicItem?.id === "didYouMeanRenderer" ) { didYouMean = JSON.parse(searchJson.Search.Results.DynamicItem.Title);
}
renderTemplate(res, req, "search.ejs", {
search({'query': `${req.query.query}`}).then(results => {
renderTemplate(res, req, "search.ejs", {
j: searchJson,
IsOldWindows,
h: didYouMean,
tab,
continuation,
results:results,
q: query,
summary: "",
});
}).catch(e => {
console.log(e)
})
} catch (error) {
console.error(`Error while searching for '${query}':`, error);
res.redirect("/");