mirror of
https://codeberg.org/ashley/poke.git
synced 2025-06-07 13:33:02 -04:00
Update src/libpoketube/init/pages-static.js
This commit is contained in:
parent
33cb84b340
commit
c2aa651b68
1 changed files with 8 additions and 8 deletions
|
@ -82,23 +82,23 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
renderTemplate(res, req, "rewind.ejs");
|
renderTemplate(res, req, "rewind.ejs");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get("/notepad", function (req, res) {
|
||||||
|
renderTemplate(res, req, "pokepad.ejs");
|
||||||
|
});
|
||||||
|
|
||||||
app.get("/translate", async function (req, res) {
|
app.get("/translate", async function (req, res) {
|
||||||
const { fetch } = await import("undici");
|
const { fetch } = await import("undici");
|
||||||
|
|
||||||
const api_url = "https://simplytranslate.org/api/translate";
|
const api_url = "https://simplytranslate.org/api/translate";
|
||||||
|
|
||||||
// Fetch translation data
|
|
||||||
const translationResponse = await fetch(
|
const translationResponse = await fetch(
|
||||||
`${api_url}?from=${req.query.from_language}&to=${req.query.to_language}&text=${req.query.input}&engine=google`
|
`${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();
|
const translationData = await translationResponse.json();
|
||||||
|
|
||||||
// Extract translated_text from the response
|
|
||||||
const translatedText = translationData.translated_text;
|
const translatedText = translationData.translated_text;
|
||||||
|
|
||||||
// Render the template with the translated text
|
|
||||||
renderTemplate(res, req, "translate.ejs", {
|
renderTemplate(res, req, "translate.ejs", {
|
||||||
translation: translatedText,
|
translation: translatedText,
|
||||||
text: req.query.input || "enter text here",
|
text: req.query.input || "enter text here",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue