kes kes - 2 years ago 162
Scala Question

How to detect application mode in Play 2.x

From within a Play 2.1 application, how would I programmatically determine which mode the application is running in (i.e., Development vs. Production)?

For example, it would be useful to be able to do something like this from inside a template:

<p>@if(__some_play_API_call__ == Dev) { <b>Development mode</b> }</p>

In the Play 2.0 API documentation, there appears to be a
property of the
class... however, I am unsure about how to get at the instance of the currently running application.

Answer Source

You can access the current Appliction via


to find out the mode try


or simply use

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download