How to serve static page in phoenix framework?

后端 未结 1 1151
被撕碎了的回忆
被撕碎了的回忆 2021-01-04 01:36

I want to serve static page in Phoenix Framework to use it in Angular Views. I know I can serve regular HTML, but I want to get rid of the default LayoutView. I

相关标签:
1条回答
  • 2021-01-04 01:56

    You can serve static files by having a file in priv/static and matching the path in the Plug.Static options:

      plug Plug.Static,
        at: "/", from: :hello_phoenix, gzip: false,
        only: ~w(css fonts images js favicon.ico robots.txt my_fine.html)
    

    You can also bypass the layout using put_layout/2:

    conn
    |> put_layout(false)
    |> render("index.html")
    

    The put_layout/2 function can also be called as a plug (due to the function arguments). This is useful if you want it to apply to the entire controller:

    plug :put_layout, false
    
    0 讨论(0)
提交回复
热议问题