Skip to content

Instantly share code, notes, and snippets.

@ryanwinchester
Created October 30, 2024 10:40
Show Gist options
  • Save ryanwinchester/3839f18454ed45b41a0101aa12684942 to your computer and use it in GitHub Desktop.
Save ryanwinchester/3839f18454ed45b41a0101aa12684942 to your computer and use it in GitHub Desktop.
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