hudson2010
Challenge with Serving Static files
Hello guys ,
I have set up some project , but I have som e bit of challenge with serving static files with the plug module
23:03:44.817 [debug] GET /home
23:03:44.817 [debug] Sent 200 in 32µs
23:03:44.849 [debug] GET /priv/js/test.js
*23:03:44.849 [debug] Sent 404 in 24µs*
==============================
Routes :
plug(Plug.Logger, log: :debug)
plug :match
plug :dispatch
plug Plug.Static, at: "/home", from: :server, only: ~w(js css images robots.txt)
get "/" do
send_resp(conn, 200, "Hello There!")
end
get "/about/:user_name" do
send_resp(conn, 200, "Hello, #{user_name}")
end
get "/home" do
conn = put_resp_content_type(conn, "text/html")
send_file(conn, 200, "priv/index.html")
end
I need some guidance on what , I be doing wrong , your assistance will be much appreciated
Most Liked
mhanberg
Expert LSP Core Team
plug :match
plug :dispatch
plug Plug.Static, at: "/", from: :server, only: ~w(js css images robots.txt)
must become
plug Plug.Static, at: "/", from: :server, only: ~w(js css images robots.txt)
plug :match
plug :dispatch
2
mhanberg
Expert LSP Core Team
mhanberg
Expert LSP Core Team
Last Post!
Popular in Discussions
The reason that Rails is as popular as it is is because it’s very easy for relatively inexperienced developers to get a lot of work done....
New
In general I’ve been sticking to this community style guide GitHub - christopheradams/elixir_style_guide: A community driven style guide ...
New
Hi all,
In the last days, two things happened:
A blog post titled “They might never tell you it’s broken” made the rounds. It’s about ...
New
It would be nice to be able to define a redirect from one route to another from the router.ex file. E.g.:
redirect "/", UserController, ...
New
What learn first? Rust or Elixir
Hi Elixir community!
I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
Hi everyone, im working on find best language/framework/system for
high concurrency, high performance and stable performance
after wor...
New
I like Umbrella projects and pretty much always use them for personal Elixir stuff, especially Nerves things.
But I don’t think this is ...
New
Other popular topics
Hello, how can I check the Phoenix version ?
Thanks !
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
I would like to know what is the best IDE for elixir development?
New
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Chat & Discussions>Discussions
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









