SHARE
TWEET

Untitled

a guest Jul 17th, 2019 465 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <code>
  2.     <!DOCTYPE html>
  3.     <html>
  4.     <head>
  5.         <title>404 Error</title>
  6.     </head>
  7.     <style>
  8.     html,
  9.     body {
  10.         height: 100%;
  11.     }
  12.     </style>
  13.     <body>
  14.     <div class="container align-middle">
  15.     <div class="jumbotron text-center" style="
  16.         margin-top: 50px;
  17.         margin-right: 50px;
  18.         margin-left: 50px;
  19.         margin-bottom: 50px;
  20.     ">
  21.         <h1>Error 404</h1>
  22.         <h4>hmm, the page seems to be missing</h4>
  23.         <img src="fry.gif" alt="Error Image">  
  24.         <p>Please recheck your URL.</p>
  25.         <button onclick="goBack()">Go Back</button>
  26.     </div>
  27.     </div>
  28.  
  29.     <script>
  30.     function goBack() {
  31.       window.history.back();
  32.     }
  33.     </script>
  34.     </body>
  35.     </html>
  36.     </code>
  37.  
  38. here is my node code
  39.  
  40. <code>
  41. var fs = require('fs');
  42. var url = require('url');
  43. var express = require('express');
  44. var tynt = require('tynt'); //color
  45. var path = require('path');
  46. require('console-stamp')(console, { pattern: 'dd/mm/yyyy HH:MM:ss.l',colors: {stamp: 'yellow', label: 'white'}}); //timestamp
  47. var PouchDB = require('pouchdb'); //database
  48. var router = express();
  49. var port = 8080;
  50. var site = "/public";
  51.  
  52. var htmlPath = path.join(__dirname, 'public');
  53. router.use(express.static(htmlPath));
  54.  
  55. router.get('/favicon.ico', (req, res) => res.sendStatus(204));
  56.  
  57. router.get('/', function (req, res) {
  58.    console.log('=> ' + tynt.Green('Accessed - ') + 'Index Page');
  59.   res.sendFile( __dirname + '/public/index.html');
  60. });
  61.  
  62. router.get('/default', function (req, res) {
  63.    var q = url.parse(req.url, true);
  64.    var filename = (__dirname + site + q.pathname + ".html");
  65.    console.log('=> ' + tynt.Green('Accessed - ') + q.pathname + ' page');
  66.   res.sendFile(filename);
  67. });
  68.  
  69.  
  70. router.get('*', function (req, res) {
  71.   var q = url.parse(req.url, true);
  72.   var filename = (__dirname + q.pathname);
  73.   fs.readFile(filename, function(err, data) {
  74.   if (err) {
  75.     console.error('=>' + tynt.Red(' Failed to access: ') + filename);
  76.     console.error(err);
  77.     console.info('==> Serving 404 page');
  78.     res.sendFile( __dirname + '/public/404.html');
  79.       }
  80.     });
  81.   });
  82.  
  83. var server = router.listen(port, function () {
  84. console.log('Running on port ' + port);
  85. });
  86. </code>
  87.  
  88. these are the console log errors I encountered
  89. with /e
  90.  
  91. <code>
  92. => Failed to acess: E:app/e
  93. => { [Error: ENOENT: no such file or directory, open 'E:app/e']
  94. errno: -4058,
  95. code: 'ENOENT',
  96. syscall: 'open',
  97. path: 'E:\app\e' }
  98. ==> Serving 404 page
  99. </code>
  100.      
  101. <code>
  102. => Failed to acess: E:app/e
  103. => { [Error: ENOENT: no such file or directory, open 'E:app/e/any']
  104. errno: -4058,
  105. code: 'ENOENT',
  106. syscall: 'open',
  107. path: 'E:\app\e\any' }
  108. ==> Serving 404 page
  109. => Failed to acess: E:app/e/fry.gif
  110. => { [Error: ENOENT: no such file or directory, open 'E:app/e/fry.gif']
  111. errno: -4058,
  112. code: 'ENOENT',
  113. syscall: 'open',
  114. path: 'E:\app\e\fry.gif' }
  115. ==> Serving 404 page
  116. </code>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top