2013-09-09 15:51:41 +02:00
|
|
|
Static file handler example
|
|
|
|
===========================
|
2012-07-14 20:24:47 +02:00
|
|
|
|
2013-10-22 09:14:32 +02:00
|
|
|
To try this example, you need GNU `make` and `git` in your PATH.
|
2012-07-14 20:24:47 +02:00
|
|
|
|
2013-09-09 15:51:41 +02:00
|
|
|
To build the example, run the following command:
|
2012-07-14 20:24:47 +02:00
|
|
|
|
2013-09-09 15:51:41 +02:00
|
|
|
``` bash
|
|
|
|
$ make
|
2012-07-14 20:24:47 +02:00
|
|
|
```
|
2013-09-09 15:51:41 +02:00
|
|
|
|
|
|
|
To start the release in the foreground:
|
|
|
|
|
|
|
|
``` bash
|
2014-06-30 10:14:05 +02:00
|
|
|
$ ./_rel/static_world_example/bin/static_world_example console
|
2012-07-14 20:24:47 +02:00
|
|
|
```
|
|
|
|
|
2013-09-09 15:51:41 +02:00
|
|
|
The example will serve all the files found in the `priv`
|
|
|
|
directory. For example:
|
2012-09-27 21:32:11 -07:00
|
|
|
|
2013-09-09 15:51:41 +02:00
|
|
|
* [Plain text file](http://localhost:8080/test.txt)
|
|
|
|
* [HTML5 video demo](http://localhost:8080/video.html)
|
2012-09-27 21:32:11 -07:00
|
|
|
|
2013-09-09 15:51:41 +02:00
|
|
|
Example output
|
|
|
|
--------------
|
2012-09-27 21:32:11 -07:00
|
|
|
|
|
|
|
``` bash
|
|
|
|
$ curl -i http://localhost:8080/test.txt
|
|
|
|
HTTP/1.1 200 OK
|
|
|
|
connection: keep-alive
|
|
|
|
server: Cowboy
|
2013-09-09 15:51:41 +02:00
|
|
|
date: Mon, 09 Sep 2013 13:49:50 GMT
|
2012-09-27 21:32:11 -07:00
|
|
|
content-length: 52
|
2013-09-09 15:51:41 +02:00
|
|
|
content-type: text/plain
|
|
|
|
last-modified: Fri, 18 Jan 2013 16:33:31 GMT
|
2012-09-27 21:32:11 -07:00
|
|
|
|
|
|
|
If you read this then the static file server works!
|
|
|
|
```
|