Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple Elixir Server as a Script
Mix.install([{:plug_cowboy, "~> 2.0"}])
defmodule Server do
use Plug.Router
plug(:match)
plug(:dispatch)
match _ do
send_resp(conn, 200, "Hello World!")
end
end
if System.argv() == ~w[server] do
Plug.Cowboy.http(Server, [], port: 4000)
System.no_halt(true)
end
# To install dependencies, just run: elixir app.exs
# To start server, run: elixir app.exs server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment