Whilst developing I want to handle some things slight differently than I will when I eventually upload to the Google servers.
Is there a quick test that I can do to find out if I'm in the SDK or live?
Whilst developing I want to handle some things slight differently than I will when I eventually upload to the Google servers.
Is there a quick test that I can do to find out if I'm in the SDK or live?
I just check the httplib (which is a wrapper around appengine fetch)
A more general solution
A more general solution, which does not imply to be on a Google server, detects if the code is running on your local machine. I am using the code below regardless the hosting server:
If you use macOS you could write a more generic code:
Django developers must put this sample code in the file
settings.py
of the project.EDIT:
According to Jeff O'Neill in macOS High Sierra
socket.gethostname()
returns a string ending in ".lan".See: https://cloud.google.com/appengine/docs/python/how-requests-are-handled#Python_The_environment
Based on the same trick, I use this function in my code:
I have customized my
/etc/hosts
file in order to be able to access the local version by prepending a "l" to my domain name, that way it is really easy to pass from local to production.Example:
www.example.com
www.lexample.com