susshel
susshel

Reputation: 3

Change Angularjs existing backend to Play 2

I have a fully developed Angularjs frontend app (with the routes and everything set up) and would like to change the current backend to a Play 2 Java. What is the best approach to display the existing html files from Angular in Play? I have found a few examples of how to connect the routes, but I would rater not create an index.scala.html file as I would like to have the two frameworks separated as much as possible and having Play only working as backend.

Upvotes: 0

Views: 78

Answers (1)

Daniel Olszewski
Daniel Olszewski

Reputation: 14411

If you don't want to dynamically generate views from Play using Twirl and you just want to serve your HTML static files publishing them as assets is the way to go. By default assets are designed to provide resource like CSS or JS files but nothing prevents you from serving ordinary HTML views as well.

Simply put your index.html in the public directory and modify the conf/routes files so it can handle all requests:

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

This way your index.html will be accessible at www.yourdomain.com/index.html. Remember to put this line as the last mapping in the file as it matches all possible URLs. Other services should be declared above it.

Upvotes: 1

Related Questions