File diff 6bdc205e6aa1 → 26ff31bb7878
www/conservancy/static/views.py
Show inline comments
 
import mimetypes
 
import os.path
 
from django.http import HttpResponse
 
from django.template.response import TemplateResponse
 

	
 
from conservancy.apps.fundgoal.models import FundraisingGoal
 
from conservancy.local_context_processors import fundgoal_lookup
 

	
 
STATIC_ROOT = os.path.abspath(os.path.dirname(__file__))
 
FILESYSTEM_ENCODING = 'utf-8'
 

	
 
def handler(request, errorcode):
 
    path = os.path.join('error', str(errorcode), 'index.html')
 
    fullpath = os.path.join(STATIC_ROOT, path)
 
    if not os.path.exists(fullpath):
 
        return HttpResponse("Internal error: " + path, status=int(errorcode))
 
    else:
 
        return TemplateResponse(request, path, status=int(errorcode))