I am using node.js and express for my site. I need to be able to direct the user when he clicks a link in index.html. I have three pages: index.html, presentation.html, join.html all in the public folder. This is how I did the routing in server.js:
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.bodyParser({ keepExtensions: true, uploadDir: __dirname + '/_tmp'}));
And this is how I wrote the links in index.html:
<a class="btn" href="/presentation">Presentation</a>
<a class="btn" href="/join">Join</a>
when I run the server I get index.html but when I click one of the links to navigate to the other pages I get this error:
Cannot GET /presentation
When I try to add to server.js this:
app.get('/presentation',function(req,res){
res.render('public/presentation.html' , { root : __dirname});
});
TypeError: undefined is not a function
Here is my App layout:
App
/pulic
indx.html
join.html
presentatio.html
server.js
How can enable navigation?
Aucun commentaire:
Enregistrer un commentaire