Skip to content

Instantly share code, notes, and snippets.

@Gazler
Last active May 31, 2023 07:18
Embed
What would you like to do?
Application.put_env(:phoenix, :json_library, Jason)
Application.put_env(:sample, SamplePhoenix.Endpoint, [
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
secret_key_base: String.duplicate("a", 64)
])
Mix.install([
{:plug_cowboy, "~> 2.5"},
{:jason, "~> 1.0"},
{:phoenix, "~> 1.6"}
])
defmodule SamplePhoenix.SampleController do
use Phoenix.Controller
def index(conn, _) do
send_resp(conn, 200, "Hello, World!")
end
end
defmodule Router do
use Phoenix.Router
pipeline :browser do
plug :accepts, ["html"]
end
scope "/", SamplePhoenix do
pipe_through :browser
get "/", SampleController, :index
# Prevent a horrible error because ErrorView is missing
get "/favicon.ico", SampleController, :index
end
end
defmodule SamplePhoenix.Endpoint do
use Phoenix.Endpoint, otp_app: :sample
plug Router
end
{:ok, _} = Supervisor.start_link([SamplePhoenix.Endpoint], strategy: :one_for_one)
Process.sleep(:infinity)
@eksperimental
Copy link

@Gazler and anyone who may find this interesting I have ported the script to an Eliixir app.

https://github.com/eksperimental/lean_phoenix_server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment