To try this example, you need GNU make
and git
in your PATH
.
If you don’t have HTTPie installed, use the appropriate cURL commands instead.
To build the example, run the following command:
make
To start the release in the foreground:
./_rel/web-server-example/bin/web-server-example console
Note: The previous command also starts an Erlang console.
To start the app and an LFE shell:
lfe -pa ebin -pa deps/*/ebin -s web-server # make dev
Point your browser at http://localhost:8080 to
browse the contents of the priv
directory.
http -v :8080 Accept:text/html
GET / HTTP/1.1
Accept: text/html
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost:8080
User-Agent: HTTPie/0.9.2
HTTP/1.1 200 OK
content-length: 256
content-type: text/html
date: Sat, 02 Jan 2016 11:45:09 GMT
server: Cowboy
vary: accept
<!DOCTYPE html><html><head><title>Index</title></head><body><a href='/..'>..</a><br>
<a href='/small.mp4'>small.mp4</a><br>
<a href='/small.ogv'>small.ogv</a><br>
<a href='/test.txt'>test.txt</a><br>
<a href='/video.html'>video.html</a><br>
</body></html>
http -vj :8080
GET / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: application/json
Host: localhost:8080
User-Agent: HTTPie/0.9.2
HTTP/1.1 200 OK
content-length: 49
content-type: application/json
date: Sat, 02 Jan 2016 11:46:11 GMT
server: Cowboy
vary: accept
[
"small.mp4",
"small.ogv",
"test.txt",
"video.html"
]
http -v :8080 Accept:text/plain
GET / HTTP/1.1
Accept: text/plain
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost:8080
User-Agent: HTTPie/0.9.2
HTTP/1.1 406 Not Acceptable
content-length: 0
date: Sat, 02 Jan 2016 11:47:10 GMT
server: Cowboy