在拥有托管站点时调用样式表

时间:2021-05-25 05:03:53

So I've built a site in my directory and it can call all the stylesheets I made up just fine but when I create a local host it posts the html without any of the stylesheet. So the node would look like this

所以我在我的目录中构建了一个站点,它可以调用我编写的所有样式表,但是当我创建一个本地主机时,它会发布没有任何样式表的html。所以节点看起来像这样

app.listen(PORT, function() {
    console.log("App listening on PORT " + PORT);
});

And my html like this

我的HTML就像这样

<head><link href="custome.css" rel="stylesheet"></head>
<body> /snip </body>

So when ever I open up the local host at PORT it's blank.

因此,当我在PORT打开本地主机时,它是空白的。

1 个解决方案

#1


0  

You should serve static files. You should give more detail about the issue.

您应该提供静态文件。您应该提供有关该问题的更多详细信息。

If you're using something like express.js, you can do something like this;

如果你使用像express.js这样的东西,你可以做这样的事情;

const fs = require('fs');

app.get('/custome.css', function (req, res) {
    res.send(fs.readFileSync(__dirname+'/custome.css'));
});

#1


0  

You should serve static files. You should give more detail about the issue.

您应该提供静态文件。您应该提供有关该问题的更多详细信息。

If you're using something like express.js, you can do something like this;

如果你使用像express.js这样的东西,你可以做这样的事情;

const fs = require('fs');

app.get('/custome.css', function (req, res) {
    res.send(fs.readFileSync(__dirname+'/custome.css'));
});