How to configure the Plug.Static without Phoenix

后端 未结 3 1715
小蘑菇
小蘑菇 2021-02-05 21:22

I am trying to figure out how to configure Plug.Static without any other framework (Phoenix, Sugar, etc); just Cowboy, Plug and Elixir. I just don\'t know how t

3条回答
  •  情话喂你
    2021-02-05 21:28

    Everything that José Valim said. And here's a most simple example to add to it:

    defmodule Server do
      use Plug.Builder
      plug Plug.Logger
      plug Plug.Static, at: "/", from: "/path/to/static"
    end
    

    This will serve all static files in "/path/to/static" at the "/" endpoint.

    Have a look at the docs for more options and a deeper explanation.

提交回复
热议问题