static_world_app.erl 674 B

123456789101112131415161718192021222324252627282930313233
  1. %% Feel free to use, reuse and abuse the code in this file.
  2. %% @private
  3. -module(static_world_app).
  4. -behaviour(application).
  5. %% API.
  6. -export([start/2]).
  7. -export([stop/1]).
  8. %% API.
  9. start(_Type, _Args) ->
  10. Dispatch = cowboy_router:compile([
  11. {'_', [
  12. {"/[...]", cowboy_static, [
  13. {directory, {priv_dir, static_world, []}},
  14. {mimetypes, [
  15. {<<".html">>, [<<"text/html">>]},
  16. {<<".txt">>, [<<"text/plain">>]},
  17. {<<".mp4">>, [<<"video/mp4">>]},
  18. {<<".ogv">>, [<<"video/ogg">>]}
  19. ]}
  20. ]}
  21. ]}
  22. ]),
  23. {ok, _} = cowboy:start_http(http, 100, [{port, 8080}], [
  24. {env, [{dispatch, Dispatch}]}
  25. ]),
  26. static_world_sup:start_link().
  27. stop(_State) ->
  28. ok.