无法在" localhost:3000 /"上加载CSS文件(控制台日志中的错误);在node.js?

时间:2017-04-20 11:55:10

标签: css node.js http-status-code-404 pug middleware

enter image description here enter image description here enter image description here enter image description he[![enter image description here re] 5] 5 app.js文件:

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

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文件:

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

当我在localhost:3000 /加载浏览器时,我得到404,无法加载" localhost:3000 / css / style.css"。是什么问题???

目录结构:

  • 公共

    • CSS
      • 的style.css
  • app.js

  • 视图

    • index.jade

日Thnx

0 个答案:

没有答案