Last active
May 15, 2022 09:30
-
-
Save avinayak/e23ace8fbcc451ccb1af1cfcc56fa9cd to your computer and use it in GitHub Desktop.
Simplest plug based http sever
This file contains hidden or 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
# run with $ elixir --no-halt hello.exs | |
Mix.install([{:plug_cowboy, "~> 2.0"}]) | |
defmodule HWPlug.Plug do | |
import Plug.Conn | |
def init(options), do: options | |
def call(conn, _opts) do | |
conn | |
|> put_resp_content_type("text/plain") | |
|> send_resp(200, "Hello World!\n") | |
end | |
end | |
Plug.Adapters.Cowboy.http(HWPlug.Plug, []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment