Serve static files with ease. π
Easiest way to get started is by just typing npx serw
which will start a static HTTP server from your current directory.
β By default serw will attempt to find
public
directory and serve files from there. To avoid this behavior typeserw .
.
Alternatively, you can manually install the package globally:
npm i serw --global
...and then run it in your project's directory:
serw folder-name/ [options]
- π‘οΈ Integration with SSL/TLS certificate.
- π ETag, CORS, Cache-Control headers.
- π Basic password authentication.
- π Ignore files with support for globs.
- π¨ Customizable HTTP error handlers
To show a full list of available options run serw --help
.
Every option can be negated with --no
prefix, e.g. --no-open
or -o=false
.
π‘ You can also configure serw with
serw.json
file.
For now this package is only a CLI tool and has no built-in programmatic integration yet. I recommend against using serw
in production and only using it in development.
Type: string
Default: localhost
Hostname to bind.
Type: number
Default: 3000
Port to bind.
Type: string
Default: index.html
Path to the main page file.
Type: boolean
Default: false
Show dot files, e.g. .env
.
Type: array
List of files to ignore.
Type: boolean
Default: true
Enable directory listing.
Type: string
Default: 404.html
Path to a file to display when an error occurred.
Type: boolean
Default: true
Whether to open browser window after the server starts.
Type: boolean
Default: false
Automatically handle /robots.txt
.
Type: boolean
Default: false
Enable CORS headers.
Type: boolean
Default: false
Enable ETag headers.
Type: number
Default: undefined
Enable Cache-Control header and set maxAge
(seconds).
Type: boolean
Default: false
Appends Cache-Control header with immutable
.
Type: string
Enable simple authentication via a password.
Type: boolean
Default: false
Enable SSL/TLS for HTTPS.
Type: string
Default: key.pem
Path to SSL certificate key.
Type: string
Default: cert.pem
Path to SSL certificate file.
Type: string
Default: serw.json
Path to the config json file.
Type: boolean
Default: false
Log IP address of the client's request.
Type: boolean
Default: false
Log User-agent of the client's request.
Type: boolean
Default: true
Log timestamp.
Type: boolean
Default: true
Clear console after the server starts.
Type: boolean
Default: false
Disable logging entirely.
MIT π