github.com/inflatablewoman/deis@v1.0.1-0.20141111034523-a4511c46a6ce/controller/deis/wsgi.py (about) 1 """ 2 WSGI config for deis project. 3 4 This module contains the WSGI application used by Django's development server 5 and any production WSGI deployments. It should expose a module-level variable 6 named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover 7 this application via the ``WSGI_APPLICATION`` setting. 8 9 """ 10 11 from __future__ import unicode_literals 12 import os 13 14 from django.core.wsgi import get_wsgi_application 15 import static 16 17 18 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "deis.settings") 19 20 21 class Dispatcher(object): 22 """ 23 Dispatches requests between two WSGI apps, a static file server and a 24 Django server. 25 """ 26 27 def __init__(self): 28 self.django_handler = get_wsgi_application() 29 self.static_handler = static.Cling(os.path.dirname(os.path.dirname(__file__))) 30 31 def __call__(self, environ, start_response): 32 if environ['PATH_INFO'].startswith('/static'): 33 return self.static_handler(environ, start_response) 34 else: 35 return self.django_handler(environ, start_response) 36 37 38 application = Dispatcher()