1
0
Fork 0
mirror of https://codeberg.org/ashley/poke.git synced 2025-06-07 06:42:56 -04:00

Update src/libpoketube/init/pages-static.js

This commit is contained in:
ashley 2025-06-03 21:02:56 +02:00
parent 33cb84b340
commit c2aa651b68

View file

@ -82,23 +82,23 @@ module.exports = function (app, config, renderTemplate) {
renderTemplate(res, req, "rewind.ejs");
});
app.get("/notepad", function (req, res) {
renderTemplate(res, req, "pokepad.ejs");
});
app.get("/translate", async function (req, res) {
const { fetch } = await import("undici");
const api_url = "https://simplytranslate.org/api/translate";
// Fetch translation data
const translationResponse = await fetch(
`${api_url}?from=${req.query.from_language}&to=${req.query.to_language}&text=${req.query.input}&engine=google`
);
// Check if the request was successful (status code 200)
const translationData = await translationResponse.json();
// Extract translated_text from the response
const translatedText = translationData.translated_text;
// Render the template with the translated text
renderTemplate(res, req, "translate.ejs", {
translation: translatedText,
text: req.query.input || "enter text here",