diff options
| author | Mhykol <mchaeldonald62@pm.me> | 2024-11-03 22:42:51 -0500 |
|---|---|---|
| committer | Mhykol <mchaeldonald62@pm.me> | 2024-11-03 22:42:51 -0500 |
| commit | ef5014c8bb45e674d0a52af5cd78075da93410e4 (patch) | |
| tree | 417130e494bc0e19e52cc4815e024cff466291e5 | |
| parent | c83ba1ef865e6dd9eb2139e6e05b690252eaa56b (diff) | |
Update 404 Message
| -rw-r--r-- | app.js | 9 | ||||
| -rw-r--r-- | source/readfile.js | 3 |
2 files changed, 9 insertions, 3 deletions
@@ -105,7 +105,7 @@ class App { res.send(this.readfile.GetMain(output.get(this.path.string).meta)) } } else { - res.sendStatus(404) + res.status(404).send(this.readfile.GetMain({title: 'Page not found', description: '', keywords: ''})) } break } @@ -165,7 +165,7 @@ class App { } } } else { - res.send('Not Found') + res.send(JSON.stringify({html: this.readfile.NotFound(), css: ['main.css'], js: ['purify.js', '404.js']})) } }) }) @@ -184,7 +184,10 @@ class App { } #FileOpen(x) { x.res.set('Content-Type', x.mime) - x.data.file.on('open', () => x.data.file.pipe(x.res)).on('error', () => x.res.sendStatus(404)) + x.data.file.on('open', () => x.data.file.pipe(x.res)).on('error', () => { + x.res.set('Content-Type', mime.html) + x.res.status(404).send('File not found') + }) } #ValidateCookie(req, res, next) { const { cookies } = req diff --git a/source/readfile.js b/source/readfile.js index def56a1..3cf0a7a 100644 --- a/source/readfile.js +++ b/source/readfile.js @@ -90,6 +90,9 @@ class ReadFile { return streamToPromise(Readable.from(object.links).pipe(object.stream)).then(data => {return data.toString()}) } + NotFound() { + return fs.readFileSync('./views/layouts/404.html', 'utf-8') + } GetFile(x) { const path = x.split('/') const object = { |
