Css文件未发送到express/socket.io服务器

Css文件未发送到express/socket.io服务器,express,Express,我只需要一种方法将css链接到html,而不直接将样式应用到索引文件的。在socket.io主页上,他们已经将其放入,但当然没有人想要它 我在index.html文件中使用了,但它根本不起作用。我如何让它工作 res.sendFile(_dirname+'/front.css')也不起作用 var-app=require('express')(); var http=require('http')。服务器(应用程序); var io=require('socket.io')(http); ap

我只需要一种方法将css链接到html,而不直接将样式应用到索引文件的
。在socket.io主页上,他们已经将其放入
,但当然没有人想要它

我在index.html文件中使用了
,但它根本不起作用。我如何让它工作

res.sendFile(_dirname+'/front.css')也不起作用

var-app=require('express')();
var http=require('http')。服务器(应用程序);
var io=require('socket.io')(http);
app.get('/',函数(req,res){
res.sendFile(uu dirname+'/index.html');
});
io.on('连接',函数(套接字){
log(“{}用户已连接”);
socket.on('disconnect',function()){
console.log('user disconnected');
});
});
http.listen(3000,函数(){
console.log('监听*:3000');
});
io.on('连接',函数(套接字){
socket.on('chat message',函数(msg){
console.log('message:'+msg);
});
});
io.on('连接',函数(套接字){
socket.on('chat message',函数(msg){
io.emit('chat message',msg);
});
});

全球聊天应用程序
全球的
_反应
在线用户

      var socket=io(); $('.message form').submit(函数(){ emit('chat message',$('form control').val()); $('.form control').val(''); 返回false; }); //显示消息 socket.on('chat message',函数(msg){ $('.chat').append($('
    • ').text(msg)); });
    • 请参见

      将css文件放入名为public的文件夹中,并使用以下命令:

      app.use(express.static('public'));
      

      然后
      yoursite.com/front.css
      将链接到
      yourdirectory/public/front.css

      ,这是一个纯粹的明示相关问题,与socket.io无关