diff --git a/server.js b/server.js index 6c8d788..af4a79a 100644 --- a/server.js +++ b/server.js @@ -3,21 +3,21 @@ const app = express(); const path = require('path'); const PORT = process.env.PORT || 3500; -app.get('^/$|/index(.html)?', (req, res) => { +app.get(['/', '/index{.html}'], (req, res) => { //res.sendFile('./views/index.html', { root: __dirname }); res.sendFile(path.join(__dirname, 'views', 'index.html')); }); -app.get('/new-page(.html)?', (req, res) => { +app.get('/new-page{.html}', (req, res) => { res.sendFile(path.join(__dirname, 'views', 'new-page.html')); }); -app.get('/old-page(.html)?', (req, res) => { +app.get('/old-page{.html}', (req, res) => { res.redirect(301, '/new-page.html'); //302 by default }); // Route handlers -app.get('/hello(.html)?', (req, res, next) => { +app.get('/hello{.html}', (req, res, next) => { console.log('attempted to load hello.html'); next() }, (req, res) => { @@ -41,10 +41,10 @@ const three = (req, res) => { res.send('Finished!'); } -app.get('/chain(.html)?', [one, two, three]); +app.get('/chain{.html}', [one, two, three]); -app.get('/*', (req, res) => { +app.get('*name', (req, res) => { res.status(404).sendFile(path.join(__dirname, 'views', '404.html')); }) -app.listen(PORT, () => console.log(`Server running on port ${PORT}`)); \ No newline at end of file +app.listen(PORT, () => console.log(`Server running on port ${PORT}`));