简体   繁体   中英

Page not found error in Node.Js

i'm really new to node.js . and i was watching a tutorial and implementing it. but there is a problem and i can't figure it out. Now, I was trying to make a new page,and i did the following changes but the server is saying page not found and there is no error on the console in any file. Can somebody help me please.

app.js

// bunch of other code
var express = require('express');
var app = express();
var about = require('./routes/about');
app.use('/about',about);
// bunch of other code

routes/about.js

var express = require('express');
var router = express.Router();

/* GET about page. */
router.get('/', function(req, res, next) {
res.render('about', {
    title: "About",
    name: "Poloos"});
});

module.exports = router;

view/about.ejs

<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
</head>
<body>
<h1><%= title %></h1>
<p>Welcome to Sheikh's NodeJS</p>
<% include templates/navigation.ejs %>
<p>So this is the about page. The name of the character is <% name %> from     Breaking Bad!!!</p>
</body>
</html>

Sorry guys. i just found out what was wrong with this code. Turns out the code is fine, i just restarted my www file and boom, its working, that's pretty stupid of me though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM