404 page configured
This commit is contained in:
parent
8bfaa47442
commit
8c71328c71
12
server.js
12
server.js
|
@ -66,7 +66,7 @@ app.get('/rss.xml', async function (req, res) {
|
||||||
const extensionRegexp = new RegExp('\.txt', 'g')
|
const extensionRegexp = new RegExp('\.txt', 'g')
|
||||||
content = content.replace(domainRegexp, 'https://cosmic.voyage/')
|
content = content.replace(domainRegexp, 'https://cosmic.voyage/')
|
||||||
content = content.replace(extensionRegexp, '.html')
|
content = content.replace(extensionRegexp, '.html')
|
||||||
res.setHeader('content-type', 'text/xml');
|
res.setHeader('content-type', 'text/xml')
|
||||||
res.render('raw', { content: content })
|
res.render('raw', { content: content })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -76,11 +76,19 @@ app.get('/atom.xml', async function (req, res) {
|
||||||
const extensionRegexp = new RegExp('\.txt', 'g')
|
const extensionRegexp = new RegExp('\.txt', 'g')
|
||||||
content = content.replace(domainRegexp, 'https://cosmic.voyage/')
|
content = content.replace(domainRegexp, 'https://cosmic.voyage/')
|
||||||
content = content.replace(extensionRegexp, '.html')
|
content = content.replace(extensionRegexp, '.html')
|
||||||
res.setHeader('content-type', 'text/xml');
|
res.setHeader('content-type', 'text/xml')
|
||||||
res.render('raw', { content: content })
|
res.render('raw', { content: content })
|
||||||
})
|
})
|
||||||
|
|
||||||
app.use(express.static(path.join(__dirname, '/static')))
|
app.use(express.static(path.join(__dirname, '/static')))
|
||||||
app.use(express.static('/var/gopher'))
|
app.use(express.static('/var/gopher'))
|
||||||
|
|
||||||
|
app.get('*', function(req, res){
|
||||||
|
const back = '<a href="/"><span class="dim"><<</span> BACK TO COSMIC VOYAGE</a>'
|
||||||
|
const error = 'Message not found. Please try again.'
|
||||||
|
const content = back + '\n\n' + error
|
||||||
|
res.status(404)
|
||||||
|
res.render('basic', { content: content })
|
||||||
|
})
|
||||||
|
|
||||||
app.listen(port, () => console.log(`listening on port ${port}!`))
|
app.listen(port, () => console.log(`listening on port ${port}!`))
|
||||||
|
|
Loading…
Reference in New Issue