Mercurial > public > sg101
comparison gpp/apache/sg101.wsgi @ 47:6dfcbbf11243
Added a .wsgi file and an offline.html file.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 21 Jun 2009 21:26:49 +0000 |
parents | |
children | 31cb8d55e3a1 |
comparison
equal
deleted
inserted
replaced
46:0140ff687d49 | 47:6dfcbbf11243 |
---|---|
1 import os | |
2 import sys | |
3 | |
4 OFFLINE = True | |
5 | |
6 sys.path.append('/home/var/django-sites/sg101/django') | |
7 sys.path.append('/home/var/django-sites/sg101/3rdparty') | |
8 sys.path.append('/home/var/django-sites/sg101/sg101-trunk') | |
9 sys.path.append('/home/var/django-sites/sg101/sg101-trunk/gpp') | |
10 | |
11 os.environ['PYTHON_EGG_CACHE'] = '/home/var/django-sites/sg101/eggs/' | |
12 | |
13 | |
14 def offline_handler(environ, start_response): | |
15 wsgi_dir = os.path.dirname(__file__) | |
16 sys.path.append(project_dir) | |
17 | |
18 offline_file = os.path.join(wsgi_dir, '..', 'templates', 'offline.html') | |
19 if os.path.exists(offline_file): | |
20 response_headers = [('Content-type','text/html')] | |
21 response = open(offline_file).read() | |
22 else: | |
23 response_headers = [('Content-type','text/plain')] | |
24 response = 'SG101 website maintenance in progress; please check back soon.' | |
25 | |
26 if environ['REQUEST_METHOD'] == 'GET': | |
27 status = '503 Service Unavailable' | |
28 else: | |
29 status = '405 Method Not Allowed' | |
30 start_response(status, response_headers) | |
31 return [response] | |
32 | |
33 | |
34 if not OFFLINE: | |
35 os.environ['DJANGO_SETTINGS_MODULE'] = 'gpp.settings' | |
36 import django.core.handlers.wsgi | |
37 application = django.core.handlers.wsgi.WSGIHandler() | |
38 else: | |
39 application = offline_handler | |
40 |