diff options
Diffstat (limited to 'htdocs/public/instant/index.ejs')
-rw-r--r-- | htdocs/public/instant/index.ejs | 23 |
1 files changed, 23 insertions, 0 deletions
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 |