Use the official WSGI way to detect if the application is in https

http://www.python.org/dev/peps/pep-3333/