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      /   "/public", file="home.html")
GET     /css/*file"/public/css", file)
GET     /js/*file"/public/js", file)
GET     /img/*file"/public/img", file)
GET     /fonts/*file"/public/fonts", file)
#GET     /assets/*file"/public", file)

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s