2019-07-13 18:16:46 +00:00
|
|
|
defmodule UiWeb.PageController do
|
|
|
|
use UiWeb, :controller
|
|
|
|
|
|
|
|
def index(conn, _params) do
|
2019-07-24 21:56:42 +00:00
|
|
|
conn |> send_resp(201, "")
|
2019-07-13 22:28:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def instructions(conn, _params) do
|
2019-07-24 21:56:42 +00:00
|
|
|
conn |> render(:instructions)
|
2019-07-13 22:28:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def morse(conn, _params) do
|
2019-07-24 21:56:42 +00:00
|
|
|
conn |> render(:morse)
|
2019-07-13 22:28:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def start(conn, _params) do
|
2019-07-24 21:56:42 +00:00
|
|
|
response =
|
|
|
|
case MorseServer.start_morse() do
|
|
|
|
:ok -> "Started."
|
|
|
|
{:error, :already_started} -> "The process is still in progress..."
|
|
|
|
end
|
2019-07-13 22:28:47 +00:00
|
|
|
|
2019-07-24 21:56:42 +00:00
|
|
|
conn |> text(response)
|
2019-07-13 18:16:46 +00:00
|
|
|
end
|
|
|
|
end
|