Created
October 30, 2024 10:40
-
-
Save ryanwinchester/3839f18454ed45b41a0101aa12684942 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mix.install([{:bandit, "~> 1.0"}]) | |
defmodule WebServer do | |
import Plug.Conn | |
def init(opts), do: opts | |
def call(conn, _opts) do | |
case conn.path_info do | |
[] -> | |
conn | |
|> send_resp(200, "Hello World") | |
|> halt() | |
path -> | |
conn | |
|> send_resp(200, "Hello #{Enum.join(path, ", ")}") | |
|> halt() | |
end | |
end | |
end | |
Bandit.start_link(plug: WebServer) | |
Process.sleep(:infinity) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment