mirror of
https://github.com/static-web-server/static-web-server.git
synced 2026-01-25 05:06:33 +00:00
feat: support for downloading a directory as a compressed tarball (#544)
$ static-web-server -p 1234 -d ./public \
--directory-listing --directory-listing-download=targz
This commit is contained in:
@@ -72,6 +72,8 @@ Options:
|
||||
Specify a default code number to order directory listing entries per `Name`, `Last modified` or `Size` attributes (columns). Code numbers supported: 0 (Name asc), 1 (Name desc), 2 (Last modified asc), 3 (Last modified desc), 4 (Size asc), 5 (Size desc). Default 6 (unordered) [env: SERVER_DIRECTORY_LISTING_ORDER=] [default: 6]
|
||||
--directory-listing-format <DIRECTORY_LISTING_FORMAT>
|
||||
Specify a content format for directory listing entries. Formats supported: "html" or "json". Default "html" [env: SERVER_DIRECTORY_LISTING_FORMAT=] [default: html] [possible values: html, json]
|
||||
--directory-listing-download=<DIRECTORY_LISTING_DOWNLOAD>
|
||||
Specify list of enabled format(s) for directory download. Format supported: `targz`. Default to empty list (disabled) [env: SERVER_DIRECTORY_LISTING_DOWNLOAD=] [possible values: targz]
|
||||
--security-headers [<SECURITY_HEADERS>]
|
||||
Enable security headers by default when HTTP/2 feature is activated. Headers included: "Strict-Transport-Security: max-age=63072000; includeSubDomains; preload" (2 years max-age), "X-Frame-Options: DENY" and "Content-Security-Policy: frame-ancestors 'self'" [env: SERVER_SECURITY_HEADERS=] [default: false] [possible values: true, false]
|
||||
-e, --cache-control-headers [<CACHE_CONTROL_HEADERS>]
|
||||
|
||||
@@ -57,6 +57,9 @@ directory-listing-order = 1
|
||||
#### Directory listing content format
|
||||
directory-listing-format = "html"
|
||||
|
||||
#### Directory listing download format
|
||||
directory-listing-download = []
|
||||
|
||||
#### Basic Authentication
|
||||
# basic-auth = ""
|
||||
|
||||
|
||||
@@ -107,6 +107,9 @@ Specify a default code number to order directory listing entries per `Name`, `La
|
||||
### SERVER_DIRECTORY_LISTING_FORMAT
|
||||
Specify a content format for the directory listing entries. Formats supported: `html` or `json`. Default `html`.
|
||||
|
||||
### SERVER_DIRECTORY_LISTING_DOWNLOAD
|
||||
Specify list of enabled format(s) for directory download. Format supported: `targz`. Default to empty list (disabled).
|
||||
|
||||
### SERVER_SECURITY_HEADERS
|
||||
Enable security headers by default when the HTTP/2 feature is activated. Headers included: `Strict-Transport-Security: max-age=63072000; includeSubDomains; preload` (2 years max-age), `X-Frame-Options: DENY` and `Content-Security-Policy: frame-ancestors 'self'`. Default `false` (disabled).
|
||||
|
||||
|
||||
@@ -126,3 +126,15 @@ curl -iH "content-type: application/json" http://localhost:8787
|
||||
|
||||
# [{"name":"spécial directöry","type":"directory","mtime":"2022-10-07T00:53:50Z"},{"name":"index.html.gz","type":"file","mtime":"2022-09-27T22:44:34Z","size":332}]⏎
|
||||
```
|
||||
|
||||
## Directory Download
|
||||
**`SWS`** supports downloading the content of a directory as a single file when **Directory Listing** feature is enabled. To activate, specify the list of download format to enable using the `--directory-listing-download` flag or the equivalent [SERVER_DIRECTORY_LISTING_DOWNLOAD](./../configuration/environment-variables.md#server_directory_listing_download) env. Currently, `targz` format is supported.
|
||||
|
||||
```sh
|
||||
static-web-server \
|
||||
--directory-listing=true \
|
||||
--directory-listing-download=targz
|
||||
```
|
||||
|
||||
When **Directory Download** is enabled, append `?download` to a directory URL to download it. A link will also be added to the top part of **HTML** output format.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user