From 86b826788eb12971ee8a76dd05d669ac4a3c5d0e Mon Sep 17 00:00:00 2001 From: jkhsjdhjs Date: Tue, 16 Aug 2016 20:17:12 +0200 Subject: [PATCH] adds random route --- src/main.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.js b/src/main.js index 6cfd149..c516a49 100644 --- a/src/main.js +++ b/src/main.js @@ -274,6 +274,13 @@ http.createServer((req, res) => { res.end(tpl(data), 'utf-8'); }); } + else if(filePath == "./random") { + sql.query("select `id` from `f0ck`.`items` order by rand() limit 1", null, (err, rows, fields) => { + res.writeHead(301, { + Location: req.headers.host + '/' + rows[0][0].id + }); + }); + } else if(filePath == "./how") { var tpl = swig.compile(templates.how); res.writeHead(200, { 'Content-Type': 'text/html' });