var express = require('express')
, app = express()
, http = require('http')
, server = http.createServer(app);
server.listen(3000);
console.log('Server Started @ 3000');
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
app.get('/index.html', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
app.get('/game.html', function (req, res) {
res.sendfile(__dirname + '/game.html');
});
app.get('/:url', function (req, res) {
res.sendfile(__dirname + req.url);
});
app.get('/:url[.js]', function (req, res) {
res.sendfile(__dirname + req.url);
});
app.get('/:url[.css]', function (req, res) {
res.sendfile(__dirname + req.url);
});
app.get('/images/:url[.png]', function (req, res) {
res.sendfile(__dirname + req.url);
});
试试这个,希望你能有所了解
如果我的回答是错误的,请原谅我