0

Is there any way to limit handlers to the development server only (in App Engine)?

My scenario:

In dev, I have my js and css split into many files, and it's easy to debug and watch the flow like this. I have a small script which compiles these resources into 2 files (1 js and 1 css) and creates a copy of index.html which includes only these 2.

There are different paths to the original vs. compiled HTML and resources, and I'd like the production version to only include the compiled ones. Any ideas?

bruntime
  • 371
  • 2
  • 12
Yaron
  • 1,753
  • 2
  • 17
  • 20

2 Answers2

2

In the app.yaml you could skip some files and prevent them from being uploaded, while they are still accessible when working locally.

Now if you want to check if your app is running locally or in the production server you should check the SERVER_SOFTWARE variable:

import os

PRODUCTION = os.environ.get('SERVER_SOFTWARE', '').startswith('Google App Engine')
DEVELOPMENT = not PRODUCTION

Then depending on which templating language you are using you will have to pass one of the above or both of them, and based on them load either the minified versions or the actual sources.

Lipis
  • 19,958
  • 18
  • 88
  • 117
  • I kow about the SERVER_SOFTWARE thing, but that's no exactyly what I want. The skip_files gets me there half way since files won't get loaded, but I'd actually like the handlers in the yaml to be different in production mode. – Yaron Nov 09 '13 at 14:21
1

You can examine the environment at runtime to determine what mode you're in. (Lipis posted the details.) And you can use that to dynamically construct array fed to WSGIApplication to maps requests to handlers. If you're in development mode, add development-mode-only entries to that array.

Dave W. Smith
  • 21,640
  • 4
  • 33
  • 38