Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
static-server
Advanced tools
A simple http server to serve static resource files from a local directory.
A simple http server to serve static resource files from a local directory.
npm -g install static-server
static-server
-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
The server may be used as a dependency HTTP server.
var StaticServer = require('static-server');
var server = new StaticServer({
rootPath: '.', // required, the root of the server file tree
name: 'my-http-server', // optional, will set "X-Powered-by" HTTP header
port: 1337, // optional, defaults to a random port
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
}
});
server.start(function () {
console.log('Server listening to', server.port);
});
server.on('request', function (req, res) {
// req.path is the URL resource (file name) from server.rootPath
// req.elapsedTime returns a string of the request's elapsed time
});
server.on('symbolicLink', function (link, file) {
// link is the source of the reference
// file is the link reference
console.log('File', link, 'is a link to', file);
});
server.on('response', function (req, res, err, file, stat) {
// res.status is the response status sent to the client
// res.headers are the headers sent
// err is any error message thrown
// file the file being served (may be null)
// stat the stat of the file being served (is null if file is null)
// NOTE: the response has already been sent at this point
});
An special thank you to all contributors who allow this project to continue to evolve.
FAQs
A simple http server to serve static resource files from a local directory.
The npm package static-server receives a total of 21,196 weekly downloads. As such, static-server popularity was classified as popular.
We found that static-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.