Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <code>
- <!DOCTYPE html>
- <html>
- <head>
- <title>404 Error</title>
- </head>
- <style>
- html,
- body {
- height: 100%;
- }
- </style>
- <body>
- <div class="container align-middle">
- <div class="jumbotron text-center" style="
- margin-top: 50px;
- margin-right: 50px;
- margin-left: 50px;
- margin-bottom: 50px;
- ">
- <h1>Error 404</h1>
- <h4>hmm, the page seems to be missing</h4>
- <img src="fry.gif" alt="Error Image">
- <p>Please recheck your URL.</p>
- <button onclick="goBack()">Go Back</button>
- </div>
- </div>
- <script>
- function goBack() {
- window.history.back();
- }
- </script>
- </body>
- </html>
- </code>
- here is my node code
- <code>
- var fs = require('fs');
- var url = require('url');
- var express = require('express');
- var tynt = require('tynt'); //color
- var path = require('path');
- require('console-stamp')(console, { pattern: 'dd/mm/yyyy HH:MM:ss.l',colors: {stamp: 'yellow', label: 'white'}}); //timestamp
- var PouchDB = require('pouchdb'); //database
- var router = express();
- var port = 8080;
- var site = "/public";
- var htmlPath = path.join(__dirname, 'public');
- router.use(express.static(htmlPath));
- router.get('/favicon.ico', (req, res) => res.sendStatus(204));
- router.get('/', function (req, res) {
- console.log('=> ' + tynt.Green('Accessed - ') + 'Index Page');
- res.sendFile( __dirname + '/public/index.html');
- });
- router.get('/default', function (req, res) {
- var q = url.parse(req.url, true);
- var filename = (__dirname + site + q.pathname + ".html");
- console.log('=> ' + tynt.Green('Accessed - ') + q.pathname + ' page');
- res.sendFile(filename);
- });
- router.get('*', function (req, res) {
- var q = url.parse(req.url, true);
- var filename = (__dirname + q.pathname);
- fs.readFile(filename, function(err, data) {
- if (err) {
- console.error('=>' + tynt.Red(' Failed to access: ') + filename);
- console.error(err);
- console.info('==> Serving 404 page');
- res.sendFile( __dirname + '/public/404.html');
- }
- });
- });
- var server = router.listen(port, function () {
- console.log('Running on port ' + port);
- });
- </code>
- these are the console log errors I encountered
- with /e
- <code>
- => Failed to acess: E:app/e
- => { [Error: ENOENT: no such file or directory, open 'E:app/e']
- errno: -4058,
- code: 'ENOENT',
- syscall: 'open',
- path: 'E:\app\e' }
- ==> Serving 404 page
- </code>
- <code>
- => Failed to acess: E:app/e
- => { [Error: ENOENT: no such file or directory, open 'E:app/e/any']
- errno: -4058,
- code: 'ENOENT',
- syscall: 'open',
- path: 'E:\app\e\any' }
- ==> Serving 404 page
- => Failed to acess: E:app/e/fry.gif
- => { [Error: ENOENT: no such file or directory, open 'E:app/e/fry.gif']
- errno: -4058,
- code: 'ENOENT',
- syscall: 'open',
- path: 'E:\app\e\fry.gif' }
- ==> Serving 404 page
- </code>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement