From daa5662aae471537976717eee104ce4982e925e6 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 18 Jul 2017 21:40:02 -0400 Subject: [PATCH] Add cowboy web server --- priv/index.html | 8 ++++++++ src/riichi.app.src | 3 ++- src/riichi_app.erl | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 priv/index.html diff --git a/priv/index.html b/priv/index.html new file mode 100644 index 0000000..7d2fa40 --- /dev/null +++ b/priv/index.html @@ -0,0 +1,8 @@ + + + Riichi Mahjong + + +

Riichi Mahjong

+ + diff --git a/src/riichi.app.src b/src/riichi.app.src index 5bee779..0d2b4d6 100644 --- a/src/riichi.app.src +++ b/src/riichi.app.src @@ -5,7 +5,8 @@ {registered, []}, {applications, [ kernel, - stdlib + stdlib, + cowboy ]}, {modules, []}, {mod, { riichi_app, []}}, diff --git a/src/riichi_app.erl b/src/riichi_app.erl index cf619f5..cc71c03 100644 --- a/src/riichi_app.erl +++ b/src/riichi_app.erl @@ -10,6 +10,15 @@ %% =================================================================== start(_StartType, _StartArgs) -> + Dispatch = cowboy_router:compile( + [{'_', [{"/", cowboy_static, {priv_file, riichi, "index.html"}}]} + ]), + {ok, _} = cowboy:start_http( + my_http_listener, + 100, + [{port, 8080}], + [{env, [{dispatch, Dispatch}]}] + ), riichi_sup:start_link(). stop(_State) ->