From 54e73085c68804e83b8a72ae1cb9a9982eaddb06 Mon Sep 17 00:00:00 2001 From: kanadeko Date: Tue, 17 Jan 2017 15:55:27 -0300 Subject: Removed extra routes, moved static to main file --- lolisafe.js | 16 +++++++++++++--- pages/error/404.html | 47 +++++++++++++++++++++++++++++++++++++++++++++++ public/error/404.html | 47 ----------------------------------------------- routes/routes.js | 36 ------------------------------------ 4 files changed, 60 insertions(+), 86 deletions(-) create mode 100644 pages/error/404.html delete mode 100644 public/error/404.html delete mode 100644 routes/routes.js diff --git a/lolisafe.js b/lolisafe.js index 082ccef..fffe9a7 100644 --- a/lolisafe.js +++ b/lolisafe.js @@ -1,6 +1,5 @@ const config = require('./config.js') const api = require('./routes/api.js') -const routes = require('./routes/routes.js') const express = require('express') const db = require('knex')(config.database) const fs = require('fs') @@ -19,12 +18,23 @@ if( prefix !== '' ) safe.use('/' + prefix, express.static('./uploads')) safe.use('/', express.static('./public')) -safe.use('/', routes) safe.use('/api', api) +safe.get('/', function (req, res, next) { + res.sendFile('home.html', { + root: './pages/' + }) +}) + +safe.get('/panel', function (req, res, next) { + res.sendFile('panel.html', { + root: './pages/' + }) +}) + safe.use(function (req, res, next) { res.status(404).sendFile('404.html', { - root: './public/error/', + root: './pages/error/', }) }) diff --git a/pages/error/404.html b/pages/error/404.html new file mode 100644 index 0000000..1853f21 --- /dev/null +++ b/pages/error/404.html @@ -0,0 +1,47 @@ + + + + loli-safe + + + + + + +
+
+
Page not found.
+
+
+ + \ No newline at end of file diff --git a/public/error/404.html b/public/error/404.html deleted file mode 100644 index 1853f21..0000000 --- a/public/error/404.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - loli-safe - - - - - - -
-
-
Page not found.
-
-
- - \ No newline at end of file diff --git a/routes/routes.js b/routes/routes.js deleted file mode 100644 index c849335..0000000 --- a/routes/routes.js +++ /dev/null @@ -1,36 +0,0 @@ -const config = require('../config.js') -const routes = require('express').Router() -const path = require('path') - -let options = { - root: 'pages/', - dotfiles: 'deny', - headers: { - 'x-timestamp': Date.now(), - 'x-sent': true - } -} - -routes.get('/', (req, res) => { - - res.sendFile('home.html', options, function (err) { - if (err) { - console.log(err) - res.status(err.status).end() - } - }) - -}) - -routes.get('/panel', function (req, res, next) { - - res.sendFile('panel.html', options, function (err) { - if (err) { - console.log(err) - res.status(err.status).end() - } - }) - -}) - -module.exports = routes \ No newline at end of file -- cgit v1.2.3