Skip to content

Instantly share code, notes, and snippets.

@lincolnloop
Created March 13, 2009 03:22
Show Gist options
  • Save lincolnloop/78416 to your computer and use it in GitHub Desktop.
Save lincolnloop/78416 to your computer and use it in GitHub Desktop.
Django mod_wsgi scripts
import os, sys
import site
# put virtualenv on pythonpath
site.addsitedir('/path/to/project/ve/lib/python2.5/site-packages')
# redirect prints to apache log
sys.stdout = sys.stderr
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
import os, sys
import site
# put virtualenv on pythonpath
site.addsitedir('/path/to/project/ve/lib/python2.5/site-packages')
# redirect prints to apache log
sys.stdout = sys.stderr
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
import django.core.handlers.wsgi
_application = django.core.handlers.wsgi.WSGIHandler()
def application(environ, start_response):
# trick Satchmo into thinking proxied traffic is coming in via HTTPS
# HTTP_X_FORWARDED_SSL is used on WebFaction
if environ.get("HTTP_X_FORWARDED_PROTOCOL") == "https" or \
environ.get("HTTP_X_FORWARDED_SSL") == "on":
environ["wsgi.url_scheme"] = "https"
return _application(environ, start_response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment