Skip to content

Commit

Permalink
i
Browse files Browse the repository at this point in the history
  • Loading branch information
i1li committed May 11, 2024
1 parent 90c9c83 commit abd8fa0
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions serv.js
Original file line number Diff line number Diff line change
@@ -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`);
Expand All @@ -30,4 +22,4 @@ function openBrowser(url) {
default:
exec(`xdg-open ${url}`);
}
}
}

0 comments on commit abd8fa0

Please sign in to comment.