var express = require("express"); var app = express(); var port = 8080; app.use(express.static(__dirname + "/", {index: "index.html"})); app.listen(port); console.log('httpServer at http://localhost:' + port);
Koa+koa-static
1 2 3 4 5 6 7
var serve = require('koa-static'); var koa = require('koa'); var app = koa(); var port = 8080; app.use(serve('.', {index: "index.html"})); //默认为index.html app.listen(port); console.log('httpServer at http://localhost:' + port);