From 45557cdd61850abc30959c39054d29b45fefb8c2 Mon Sep 17 00:00:00 2001 From: Minteck Date: Thu, 16 Dec 2021 23:06:28 +0100 Subject: It's finally done! --- htdocs/public/instant/index.ejs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 htdocs/public/instant/index.ejs (limited to 'htdocs/public/instant') diff --git a/htdocs/public/instant/index.ejs b/htdocs/public/instant/index.ejs new file mode 100644 index 0000000..de79c9d --- /dev/null +++ b/htdocs/public/instant/index.ejs @@ -0,0 +1,23 @@ +<% + +if (typeof get["q"] !== "undefined") { + query = get["q"].toLowerCase().substr(0, 200).replace(/[^A-Za-z0-9 ]/, '').replace(/[\.]/, ' ').trim(); +} else { + res.writeHead(301, {"Location": "/" + slang}); + res.end(); +} + +if (query === "") { + res.writeHead(301, {"Location": "/" + slang}); + res.end(); +} + +if (fs.existsSync(wwwdata + "/../../data/instants/" + query.replaceAll(" ", "_"))) { + data = fs.readFileSync(wwwdata + "/../../data/instants/" + query.replaceAll(" ", "_"), 'utf-8'); +} else { + data = "{\"Abstract\":\"\",\"AbstractText\":\"\"}"; +} + +res.writeHead(200, {'Content-Type': 'application/json; charset=utf-8'}); + + %><%- data %> \ No newline at end of file -- cgit