CSS没有加载到Web服务器上

时间:2017-04-27 19:39:37

标签: javascript css nginx server semantic-ui

我正在nginx服务器上构建一个网站,并希望使用semantic-ui模板。我正在使用带有express的node.js,但是CSS却没有加载......控制台说它无法找到文件,但是当我在本地机器上运行代码时,它运行正常。有没有人遇到过这个?

继承我的代码:

app.js

var express     = require('express');
var app         = express();
var path        = require('path');

app.set('view engine', 'ejs');
app.use(express.static('/public'));
app.set('views', path.join(__dirname, 'views'));


require('./routes/routes')(app);

app.listen(8000, function () {
    console.log('server running on port 8000')
});

路由/ routes.js

module.exports = function (app) {

    app.get('/', function (req, res) {
        res.render('construction.ejs');
    });
};

construction.ejs

<!DOCTYPE html>
<html>
<head>
    <title>My website</title>

    <link rel="stylesheet" type="text/css" href="semantic/dist/semantic.min.css">
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"
        integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
        crossorigin="anonymous"></script>
    <script src="semantic/dist/semantic.min.js"></script>
</head>
<body>
    <div class="ui container raised very padded text segment">
        <h1>WELCOME!!</h1>
        <p>This page is still under construction...</p>
        <p>Check back in a few weeks ;-)</p>
    </div>
</body>
</html>

0 个答案:

没有答案