From 28f90b81fa25ebba578bc1b449ddf66d1a82ea3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 9 Sep 2013 15:51:41 +0200 Subject: Convert the static handler example to a release Temporarily hardcode the list of mimetypes. --- examples/static_world/README.md | 52 +++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 31 deletions(-) (limited to 'examples/static_world/README.md') diff --git a/examples/static_world/README.md b/examples/static_world/README.md index e947ebb..6d79948 100644 --- a/examples/static_world/README.md +++ b/examples/static_world/README.md @@ -1,49 +1,39 @@ -Cowboy Static File Handler -========================== +Static file handler example +=========================== -To compile this example you need rebar in your PATH. +To try this example, you need GNU `make`, `git` and +[relx](https://github.com/erlware/relx) in your PATH. -Type the following command: -``` -$ rebar get-deps compile -``` +To build the example, run the following command: -You can then start the Erlang node with the following command: +``` bash +$ make ``` -./start.sh + +To start the release in the foreground: + +``` bash +$ ./_rel/bin/hello_world_example console ``` -Cowboy will serve all the files you put in the priv/ directory. -You can replace the filename given in the example URL with the -one of a file you added to this directory to receive that file. +The example will serve all the files found in the `priv` +directory. For example: -Example -------- + * [Plain text file](http://localhost:8080/test.txt) + * [HTML5 video demo](http://localhost:8080/video.html) -Show that the file is returned as an octet-stream +Example output +-------------- ``` bash $ curl -i http://localhost:8080/test.txt HTTP/1.1 200 OK connection: keep-alive server: Cowboy -date: Fri, 28 Sep 2012 04:19:40 GMT +date: Mon, 09 Sep 2013 13:49:50 GMT content-length: 52 -Content-Type: application/octet-stream -Last-Modified: Fri, 28 Sep 2012 04:01:20 GMT +content-type: text/plain +last-modified: Fri, 18 Jan 2013 16:33:31 GMT If you read this then the static file server works! ``` - -Finally download and cat the file to verify - -``` bash -$ curl -sLO http://localhost:8080/test.txt -$ cat test.txt -If you read this then the static file server works! -``` - -HTML5 Video Example -------------------- - -Open http://localhost:8080/video.html in your favorite browser. -- cgit v1.2.3