From 95db3247485b2d1ed553c98e2231379e58a0ace2 Mon Sep 17 00:00:00 2001 From: Chris Knight Date: Sat, 12 Sep 2020 13:03:18 +0100 Subject: doc: improve Examples (#7428) --- docs/examples/file_server.md | 53 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 6 deletions(-) (limited to 'docs/examples/file_server.md') diff --git a/docs/examples/file_server.md b/docs/examples/file_server.md index 4559b5e3d..7235c84ad 100644 --- a/docs/examples/file_server.md +++ b/docs/examples/file_server.md @@ -1,22 +1,63 @@ -## File server +# File server -This one serves a local directory in HTTP. +## Concepts + +- Use the Deno standard library + [file_server.ts](https://deno.land/std@$STD_VERSION/http/file_server.ts) to + run your own file server and access your files from your web browser +- Run [Deno install](../tools/script_installer.md) to install the file server + locally + +## Example + +Serve a local directory via HTTP. First install the remote script to your local +file system. This will install the script to the Deno installation root's bin +directory, e.g. `/home/alice/.deno/bin/file_server`. ```shell deno install --allow-net --allow-read https://deno.land/std@$STD_VERSION/http/file_server.ts ``` -Run it: +You can now run the script with the simplified script name. Run it: ```shell $ file_server . Downloading https://deno.land/std@$STD_VERSION/http/file_server.ts... [...] -HTTP server listening on http://0.0.0.0:4500/ +HTTP server listening on http://0.0.0.0:4507/ ``` -And if you ever want to upgrade to the latest published version: +Now go to [http://0.0.0.0:4507/](http://0.0.0.0:4507/) in your web browser to +see your local directory contents. + +## Help + +Help and a complete list of options are available via: ```shell -file_server --reload +file_server --help +``` + +Example output: + +``` +Deno File Server + Serves a local directory in HTTP. + + INSTALL: + deno install --allow-net --allow-read https://deno.land/std/http/file_server.ts + + USAGE: + file_server [path] [options] + + OPTIONS: + -h, --help Prints help information + -p, --port Set port + --cors Enable CORS via the "Access-Control-Allow-Origin" header + --host Hostname (default is 0.0.0.0) + -c, --cert TLS certificate file (enables TLS) + -k, --key TLS key file (enables TLS) + --no-dir-listing Disable directory listing + + All TLS options are required when one is provided. ``` -- cgit v1.2.3