Sunday, 23 April 2017

Jade, express, node.js: Cannot GET /index.html showing in browser

I cant understand why i'm getting this error on my browser when i try to display my index.jade file:*

   - Cannot GET /index.html

*My app.js file is a follows:*


    var express = require('express');


    var app = express();

    var port = process.env.PORT || 5000;


    app.use(express.static('public'));
    app.set('views', './src/views');
    app.set('view engine', 'jade');

    app.get('/', function (req, res) {

        res.render('index');

    });


    app.get('/books', function (req, res) {

        res.send('Your books are here');

    });


    app.listen(port, function (Error) {
        console.log('Running server on port ' + port);
    });

and my file structure is as follows:

-> app.js
-> public
-> src
   -> views
      -> index.html
      -> index.jade

Any help would be great

Thanks :)



via julian_dragoi

No comments:

Post a Comment