From 03ebaa6c1eb165c9e2623897e98d18dd3daa5b5a Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Sat, 18 Jun 2022 00:43:49 -0400 Subject: [PATCH] express server changes (local) --- index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index b0b0252..09098f7 100644 --- a/index.js +++ b/index.js @@ -43,13 +43,27 @@ let console = process.platform == 'win32' ? new AsyncConsole("", input => { // dev environment if (config.hostDevFiles) { + let express_logger = new (require("./src/Logger"))("Express Server"); const express = require('express'); const app = express(); const path = require('path'); - app.listen(8075, () => { + var http = require('http'); + + let dir = path.join(__dirname, 'mpp.hri7566.info'); + app.use(express.static(path.join(__dirname, dir))); + + app.get('*', (req, res, next) => { + let file = path.join(dir, req.path); + if (fs.existsSync(file)) { + res.sendFile(file); + } else { + res.sendFile(path.join(dir, 'index.html')); + } }); - app.use(express.static(path.join(__dirname, 'mpp.hri7566.info'))); + const express_port = 8075; + + http.createServer(app).listen(express_port); } if (config.enableMPPCloneBot) {