eugene
eugene

Reputation: 41665

play 2.0 serve static file

I want localhost/assets/abc.png file to be served from project_root/assets/abc.png

GET /assets/*file controllers.Assets.at(path="/public", file)

With the routes above, localhost/assets/abc.png won't be served( I couldn't find a way)
but localhost/assets/images/abc.png will be served from root/assets/images/abc.png.

Upvotes: 1

Views: 703

Answers (1)

Pere Villega
Pere Villega

Reputation: 16439

Add the following entry at the bottom of routes:

# Serves only abc.png from root public folder
GET     /$file<abc.png>        controllers.Assets.at(path="/public", file)

That said, if you have multiple files to serve like this, better put them in a subfolder

Upvotes: 2

Related Questions