@funnyzak/http-server
v0.2.3
Published
a static http server
Downloads
31
Maintainers
Readme
a simple static http server
it is a simple static HTTP server node module.
Getting Started
- With npm, run
npm install @funnyzak/http-server
const StaticHttpServer = require('@funnyzak/http-server')
Usage
Here is an example that:
- create a new server instance
- start server.
const StaticHttpServer = require('@funnyzak/http-server');
const rootPath = process.cwd();
const server = new StaticHttpServer({
host: '127.0.0.1', // host
port: 16808, // listen port
root: rootPath, // static root directory
cors: true, // allow cors
compress: true, // compress response
cache: {
maxAge: 3600,
expires: true, // is set expires
cacheControl: true, // is set cacheControl
lastModified: true,
etag: true
}
});
// start server
server.serve();
// close server
setTimeout(server.dispose, 5000);
// conversion of resource path to virtual path under Root
var virtualUrl = server.parseVirtualPath(resourcePath);
Author
| | | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | funnyzak |
License
Apache-2.0 License © 2021 funnyzak