From abd8fa0c4faa21569d442e3f6072bd626004edd0 Mon Sep 17 00:00:00 2001 From: i1li <74943880+i1li@users.noreply.github.com> Date: Sat, 11 May 2024 15:14:58 -0500 Subject: [PATCH] i --- serv.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/serv.js b/serv.js index 3b231ed..ac9d0ae 100644 --- a/serv.js +++ b/serv.js @@ -1,19 +1,11 @@ +const PORT = process.env.PORT || 5000; const express = require('express'); const serv = express(); -const path = require('path'); const { exec } = require('child_process'); -const PORT = process.env.PORT || 5000; -serv.use(express.static(path.join(__dirname))); -serv.get('/', (req, res) => { - res.sendFile(path.join(__dirname, 'index.html')); -}); +serv.use(express.static(__dirname)); serv.get('*', (req, res) => { + res.sendFile(__dirname + '/index.html'); new URL(req.url, `http://${req.headers.host}`); - res.sendFile(path.join(__dirname, 'index.html'), (err) => { - if (err) { - res.status(404).send('404 Not Found'); - } - }); }); serv.listen(PORT, () => { console.log(`Server is running on port ${PORT} - \x1b[34mhttp://localhost:${PORT}/\x1b[0m`); @@ -30,4 +22,4 @@ function openBrowser(url) { default: exec(`xdg-open ${url}`); } -} \ No newline at end of file +}