Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Client Server

client_server.livemd

Client Server

Setup

Mix.install([
  :plug_cowboy,
  :req
])

Server

defmodule Server do
  use Plug.Router
  plug(Plug.Logger)
  plug(:match)
  plug(:dispatch)

  match _ do
    send_resp(conn, 200, "Hello, World!")
  end
end

plug_cowboy = {Plug.Cowboy, plug: Server, scheme: :http, port: 4000}
{:ok, _} = Supervisor.start_link([plug_cowboy], name: Server.Supervisor, strategy: :one_for_one)
Process.sleep(:infinity)

Client

Req.get!("http://localhost:4000").body