how to use plug.static

I want to create a fileserver in elixir.

just like go

http.ListenAndServe(":8080", http.FileServer(http.Dir("/files/path")))

then, i found Plug.Static, but i can’t make it work, plz help me.

my project just like this:
.
├── lib
│ ├── my_plug.ex
│ └── ser.ex
├── mix.exs
├── mix.lock
├── priv
│ └── static
├── ser
└── test
├── ser_test.exs
└── test_helper.exs

and my_plug is

defmodule MyPlug do
  use Plug.Builder

  plug Plug.Static,
    at: "/public",
    from: :ser,
    only: ~w(images robots.txt)
  plug :not_found

  @spec not_found(Plug.Conn.t(), any) :: Plug.Conn.t()
  def not_found(conn, _) do
    send_resp(conn, 404, "not found")
  end
end
 

my ser.ex is

defmodule Ser do

  def start_server do
    Plug.Cowboy.http(MyPlug, [], port: 3000)
    :timer.sleep(:infinity)
  end

  def start(_args, _x) do
    IO.puts("hello world")
    start_server()
  end
end

Do you have a constraint that you cannot use phoenix? For beginners, it is much easier to use the scaffolding of mix phx.new

https://hexdocs.pm/phoenix/Mix.Tasks.Phx.New.html