public
Last active

Django mod_wsgi scripts

  • Download Gist
django.wsgi
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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()
django_satchmo.wsgi
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
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)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.