Django

Code

Ticket #5727: views_static__serve_file.diff

File views_static__serve_file.diff, 0.8 kB (added by Thomas Güttler <hv@tbz-pariv.de>, 2 years ago)
  • django/views/static.py

    old new  
    4646        raise Http404, "Directory indexes are not allowed here." 
    4747    if not os.path.exists(fullpath): 
    4848        raise Http404, '"%s" does not exist' % fullpath 
     49    return serve_file(request, fullpath) 
     50 
     51def serve_file(request, fullpath): 
     52    """ 
     53    If you don't want to server static files with apache/lighttpd, 
     54    you can use this method. 
     55    One reason might be, that you need to check permissions before you allow 
     56    access to this file. 
     57    """ 
    4958    # Respect the If-Modified-Since header. 
    5059    statobj = os.stat(fullpath) 
    5160    if not was_modified_since(request.META.get('HTTP_IF_MODIFIED_SINCE'),