Node static server
A simple http server to serve static resource files from a local directory.
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-server
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
-c, --cors <pattern> Cross Origin Pattern. Use "*" to allow all origins
-z, --no-nocache disable cache (http 304) responses.
-o, --open open server in the local browser
Using as a node module
The server may be used as a dependency HTTP server.
Example
var StaticServer = ;var server = rootPath: '.' // required, the root of the server file tree port: 1337 // required, the port to listen name: 'my-http-server' // optional, will set "X-Powered-by" HTTP header host: '10.0.0.100' // optional, defaults to any interface cors: '*' // optional, defaults to undefined followSymlink: true // optional, defaults to a 404 error templates: index: 'foo.html' // optional, defaults to 'index.html' notFound: '404.html' // optional, defaults to undefined ; serverstart { console;}; server; server; server;
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.
Contributors
An special thank you to all contributors who allow this project to continue to evolve.