summaryrefslogtreecommitdiff
path: root/openstack-dashboard/dashboard/wsgi/django.wsgi
blob: 9c821ecbeef9dfebdc2e400627e3ce427219e578 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import logging
import os
import sys
import django.core.handlers.wsgi
from django.conf import settings

os.environ['DJANGO_SETTINGS_MODULE'] = 'dashboard.settings'
sys.stdout = sys.stderr

DEBUG = False

class WSGIRequest(django.core.handlers.wsgi.WSGIRequest):
    def is_secure(self):
        value = self.META.get('wsgi.url_scheme', '').lower()
        if value == 'https':
            return True
        return False

class WSGIHandler(django.core.handlers.wsgi.WSGIHandler):
    request_class = WSGIRequest

_application = WSGIHandler()

def application(environ, start_response):
    environ['PATH_INFO'] = environ['SCRIPT_NAME'] + environ['PATH_INFO']
    environ['wsgi.url_scheme'] = environ.get('HTTP_X_URL_SCHEME', 'http')

    return _application(environ, start_response)