src/hp/wsgi.py
author ymh <ymh.work@gmail.com>
Wed, 07 Nov 2012 11:48:38 +0100
changeset 37 b4ed8cdc654c
permissions -rw-r--r--
update virtualenv + create the first file structure
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
"""
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
WSGI config for hp project.
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
This module contains the WSGI application used by Django's development server
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
and any production WSGI deployments. It should expose a module-level variable
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
this application via the ``WSGI_APPLICATION`` setting.
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
Usually you will have the standard Django WSGI application here, but it also
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
might make sense to replace the whole Django WSGI application with a custom one
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
that later delegates to the Django one. For example, you could introduce WSGI
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
middleware here, or combine a Django application with an application of another
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
framework.
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
"""
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
import os
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hp.settings")
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
# This application object is used by any WSGI server configured to use this
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
# file. This includes Django's development server, if the WSGI_APPLICATION
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
# setting points here.
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
from django.core.wsgi import get_wsgi_application
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
application = get_wsgi_application()
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
# Apply WSGI middleware here.
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
# from helloworld.wsgi import HelloWorldApplication
b4ed8cdc654c update virtualenv + create the first file structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
# application = HelloWorldApplication(application)