From ef6eb8949fa20f9e2edfd1c836c4ada94c00e4c8 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Tue, 21 Jun 2022 21:37:27 -0700 Subject: [PATCH] Add script --- index.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..31adb62 --- /dev/null +++ b/index.js @@ -0,0 +1,17 @@ +const app = require("express")(); +app.use(require("cors")()); + +const fetch = require("node-fetch"); + +app.get("/", (request, response) => { + response.writeHead(200, { "Content-Type": "application/json" }); + const term = "漢字"; + fetch("https://tatoeba.org/en/api_v0/search" + request.url.substring(request.url.indexOf("?"))) + .then(response => response.text()) + .then(body => { + response.write(body); + response.end(); + }); +}); + +app.listen(process.argv[2] ? process.argv[2] : 3000);