Thursday 20 April 2017

Can't load css file error in console log in node.js?

app.js file:

const express = require('express'),
  app = express(),
  path = require('path');

app.use(express.static(__dirname + '/public'));

app.set('view engine', 'jade');
app.set('views', './views');

app.get('/', (req, res) => {
  res.render('index')
});

app.listen(3000);
console.log('listening on port 3000');

index.jade file:

doctype 
html
  head 
    title Home 
    link(rel='stylesheet', href='/css/style.css')
  body
    header
      h1 Home
    footer
      p Designed By Kosta Pontidas

When I load the browser, I get 404, failed to load "localhost:3000/style.css"

Whats the problem?

directory structure:

root - public - css -style.css app.js views - index.jade

Thnx



via koz

No comments:

Post a Comment