
Node static server
A simple http server to serve static resource files from a local directory and watching.
fork from static-server , but extend below feature:
- Auto refresh when file changed.
- Command changed from
static-serverto static
Getting started
- Install node.js
- Install npm package globally
npm -g install static-server
- Go to the folder you want to serve
- Run the server
static
Options
-h, --help output usage information
-V, --version output the version number
-p, --port <n> the port to listen to for incoming HTTP connections
-i, --index <filename> the default index file if not specified
-f, --follow-symlink follow links, otherwise fail with file not found
-d, --debug enable to show error messages
-n, --not-found <filename> the error 404 file
Using as a node module
The server may be used as a dependency HTTP server.
Example
var StaticServer = require('static-dev-server');
var server = new StaticServer({
rootPath: '.',
name: 'my-http-server',
port: 1337,
host: '10.0.0.100',
cors: '*'
followSymlink: true,
templates: {
index: 'foo.html',
notFound: '404.html'
}
});
server.start(function () {
console.log('Server listening to', server.port);
});
server.on('request', function (req, res) {
});
server.on('symbolicLink', function (link, file) {
console.log('File', link, 'is a link to', file);
});
server.on('response', function (req, res, err, file, stat) {
});
FAQ
- Can I use this project in production environments? Obviously not.
- Can this server run php, ruby, python or any other cgi script? No.
- Is this server ready to receive thousands of requests? Preferably not.
License
The MIT License (MIT)