This repository was archived by the owner on Feb 16, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
executable file
·77 lines (65 loc) · 2.2 KB
/
app.py
File metadata and controls
executable file
·77 lines (65 loc) · 2.2 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
# CirruxCache provides dynamic HTTP caching on AppEngine (CDN like)
# Copyright (C) 2009 Samuel Alba <sam.alba@gmail.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
"""CirruxCache provides dynamic HTTP caching on AppEngine (CDN like)
http://cirrux.org/cache/
http://code.google.com/p/cirruxcache/
"""
__version__ = '0.4.2'
__author__ = [
'Samuel Alba <sam.alba@gmail.com>'
]
__license__ = 'GNU Public License version 2'
import sys, os
root = os.path.dirname(os.environ['PATH_TRANSLATED'])
sys.path.append(os.path.join(root, 'lib'))
sys.path.append(os.path.join(root, 'contrib'))
import logging
import web
import config
from services.cron import Cron
from services.admin import Admin
from services.store import Store
from services.debug import Debug
class Root(object):
def GET(self, request):
web.header('Content-Type', 'text/plain')
content = 'CirruxCache (%s) / http://code.google.com/p/cirruxcache/\n' % __version__
if request:
raise web.HTTPError(status='404 Not Found', data=content)
return content
class VhostMapper(object):
def __iter__(self):
base = (
'/_admin/(.*)', 'Admin',
'/_store/(.*)', 'Store',
'/_cron/(.*)', 'Cron'
)
url = ()
urls = config.urls
if 'HTTP_HOST' in web.ctx.environ:
vhost = web.ctx.environ['HTTP_HOST']
if vhost in urls:
url = urls[vhost]
elif 'default' in urls:
url = urls['default']
return iter(base + url + ('/(.*)', 'Root'))
if __name__ == '__main__':
# logging.getLogger().setLevel(logging.DEBUG)
app = web.application(VhostMapper(), globals())
app.cgirun()