Single page app with play framework

I wanted to use play framework for providing the REST APIs to a single page web app.

The web app comprises of static components – html, css, js and image files. I did not want play framework to render the UI (push), but wanted my UI to pull data from the REST APIs hosted on play server.

I had to modify the default routes conf file as below for this to work. This ensures that static web components are served correctly.

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

# Home page
# GET     /                           controllers.Application.index()
GET    /exampleapi      controllers.Application.exampleapi(input)

# Map static resources from the /public folder to the /assets URL path
GET      /             controllers.Assets.at(path="/public", file="home.html")
GET     /css/*file     controllers.Assets.at(path="/public/css", file)
GET     /js/*file     controllers.Assets.at(path="/public/js", file)
GET     /img/*file     controllers.Assets.at(path="/public/img", file)
GET     /fonts/*file     controllers.Assets.at(path="/public/fonts", file)
#GET     /assets/*file     controllers.Assets.at(path="/public", file)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s