diff options
Diffstat (limited to 'postgresqleu/static/views.py')
-rw-r--r-- | postgresqleu/static/views.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/postgresqleu/static/views.py b/postgresqleu/static/views.py new file mode 100644 index 00000000..108d9424 --- /dev/null +++ b/postgresqleu/static/views.py @@ -0,0 +1,23 @@ +from django.shortcuts import render_to_response +from django.http import HttpResponse, Http404 +from django.template import TemplateDoesNotExist, loader, Context + +# Fallback handler for URLs not matching anything else. Fall them +# back to a static template. If that one is not found, send a 404 +# error. +def static_fallback(request, url): + try: + # Disallow all URLs that back-step + if url.find('..') > -1: + raise TemplateDoesNotExist + + t = loader.get_template('pages/%s.html' % url) + return HttpResponse(t.render(Context())) + + except TemplateDoesNotExist, e: + raise Http404('Page not found') + +# Handle the frontpage +def index(request): + return render_to_response('index.html') + |