2015-11-03 138 views
0

我使用快递建设socket.io应用,最初有index.html中所有的CSS/JS和使用快递无法加载资源CSS/JS

var app = require('express')(); 
var http = require('http').Server(app); 
var io = require('socket.io')(http); 

app.get('/', function(req, res){ 
    res.sendfile('index.html'); 
}); 

但现在我分裂CSS/JS到单独的文件app.cssapp.js但当我启动应用程序和访问控制台中的页面登录浏览器我得到

未能加载CSS/JS的资源错误,我应该怎么做,因此它也允许单独的CSS/JS?

回答

1
var express = require('express'), 
    app = express(), 
    http = require('http').Server(app), 
    io = require('socket.io')(http); 

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

index.html将显示在http://localhost:[port]